Monday 15 February 2010

c# - Method takes significant amount of time to return values -



c# - Method takes significant amount of time to return values -

im dealing scenario in c#.net im loading page, , during pageload event, service beingness called populate value used diplay on page.

the page has other fields. issue here is, service takes between 30 60 secs homecoming value, other fields cannot selected until service returns value. there "save" button cannot clicked since still waiting on service homecoming value.

the problem im trying solve here is, ideally, on pageload, want service run on background , allow other fields populate value , should able execute other events save, next page, previous page etc when called.

the purpose of value returned service reference only. code not have dependency on value.

if service has method phone call making onpageload callback async , await asynchronous method within of it.

if service not have async method phone call can create own e.g:

public string downloadstringasync() { homecoming "test data"; } public async task<string> receivestringasync() { homecoming await task<string>.run(() => { //method download info homecoming downloadstringasync(); }); }

and await in page load: sting info = await receivestringasync();

you not providing plenty information/code improve answer.

c# .net multithreading asynchronous

No comments:

Post a Comment