tags:

views:

518

answers:

5

I have a btnSave_Click() function in my code-behind. If a user clicks the save button (image) I created, it calls this function:

protected void btnSave_Click(object sender, EventArgs e)
{
this.saveForm();
txtMessages.Text = "Save Complete";
}

The saveForm() function obviously saves the form (through stored procedures). Will .NET wait until that save is complete before displaying the "Save Complete" message, or is there something else I should be doing to let the user know when the save is done.

What's the best tutorial for this type of thing (i.e. spinner and notification of when save is complete)?

A: 

It will only show "Save Complete" once the previous operation is complete.

I typically put these types of messages in a statusbar. But it really depends on your application and UI.

JTA
A: 

Yes. It is top down.

I could add that if your save form logic could take awhile it might be better to spin it into a background thread to prevent locking up the GUI. Here is some good background reading on that. http://www.yoda.arachsys.com/csharp/threads/

Echostorm
+1  A: 

Yes, unless you are doing something to start a secondary thread inside the "SaveForm" method the next line will not be rendered until the entire saveForm method is done.

Mitchel Sellers
+5  A: 

This is a synchronous method. It's going to wait until the saveForm() method has returned (exited) it's completion before it can move on.

Chad Moran
A: 

Just about anything you will do inside the .Net framework is synchronous unless you specifically try to make it asynchronous.

This means that the step will wait for the return (and the stored proc call will wait for the return from SQL) before moving to the next step.

Carlton Jenke