Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 02, 2012 05:19 AM by shafkatlee
Feb 28, 2012 12:36 PM|LINK
Some time, i posted on MSDN forum asking for a help, and people in there are told me to ask for my question here because they told me i need to solve my problem with AJAX, but have no idea how, thats was my question on MSDN:
im trying to understand better async and sync, for that i need some help.
I create a simple project(windows form) with 2 buttons(sync, async), the code below:
private void button1_Click(object sender, EventArgs e)
label1.Text = "Task Completed";
private async void button2_Click(object sender, EventArgs e)
label2.Text = await ProcessDataAsync1();
label4.Text = await ProcessDataAsync2();
label5.Text = await ProcessDataAsync3();
public Task<string> ProcessDataAsync1()
return TaskEx.Run(() =>
return "Task 1 Completed";
Using this code, works like i want, if i click on the sync button, my form doest not allow me to do anything until the request finish, and if i click on the async button, this request will fill my labels one by one, even if i click on the sync during this request, the async request will continue filling my labels.
So my question, on webforms, the behavior is different, if i use the same code, the request will fill my labels together and only at the END of request.
How should i work to have on my webForm the same behavior that i have on my windowsform?
thankz in advance!
Feb 28, 2012 01:09 PM|LINK
when i ask that o msnd , i recevei this as answer:
In the world of WinForms and WebForms async updates to the UI are handled in very different ways. The reason that you see the behavior you do is because the async processes run asynchronously on the server side, but the server waits for them to finish before
for each label.
Feb 28, 2012 01:10 PM|LINK
Feb 28, 2012 02:20 PM|LINK
Have you done any research on AJAX?
That would be my first step.
Feb 28, 2012 04:14 PM|LINK
All people who answer told me to use AJAX, but i search a lot, and nothing that im found helps me.
you know how can solve this problem?
Feb 28, 2012 04:26 PM|LINK
check this site: for basic AJAX and details.
Feb 28, 2012 04:45 PM|LINK
i dont have any doubts about AJAX, just dont have any ideas, to how solve this problem. thats the reason why i ask here.
Feb 29, 2012 10:56 AM|LINK
someone here, knows how could i solve that, using AJAX?
Mar 01, 2012 06:26 AM|LINK
I'm not sure if I can explain clearly since that might require many cross knowledge between winform, webform, async and ajax here.
first, the original code (you use for demonstration in winform) which is not applicable in webform. As you've got answer from MSDN forum, webform(ASP.NET page) has different underlying UI generation and threading model.
If time allowed, strongly recommend you get more ideas about how ASP.NET page processing pipeline and lifecycle work:
#A low-level Look at the ASP.NET Architecture
#ASP.NET Page Life Cycle Overview
Then, about the AJAX approach. I think we defintely need to know what AJAX provides and its strength(unfortunately, it's better to understand the above ASP.NET server-side model first so that we can better understand why we should use AJAX).
In short, if you do not use AJAX and put all the code normally in ASP.NET webform's button_click event, the page will postback and after the work in button_click finished, write response back to client. What the AJAX do is make the postback in background. So
#Easy Ajax with jQuery Article
#Using jQuery for AJAX in ASP.NET
#Using jQuery with ASP.NET - A Beginner's Guide
#Using jQuery with ASP .NET
Mar 02, 2012 05:19 AM|LINK
You should try AJAX.
AJAX is Async technology foe WEb.