c# .net WCF Eventhandler completion -


how determine when eventhandler wcf complete?

i have 2 static variables don't set until loop using check status complete.

  1. create variables , call wcf using asynch functions created

    static var globalresults; static bool myeventcomplete; main() {     globalresults = null;     myeventcomplete = false;      wcfclient wcf = new wcfclient();      //create event handler wcf asynch call                     wcf.myfunccompleted += new eventhandler<myfunccompletedeventargs>wcf_myfunccompleted);     wcf.myfuncasync(wcfparameter.tostring());      int counter = 1;      //need determine when event handler complete use data returned wcf     while (myeventcomplete == false && globalresults == null && counter < 10000)     {          counter++;     } } 

//eventhandler

public static void wcf_myfunccompleted(object sender, myfunccompletedeventargs e) {             globalresults = e.result;             myeventcomplete = true; } 

the eventhandler updates variables after loop has completed.

if duplicate loop 2 sections - variables updated in between 2 loops - seems event handler isn't running until after loop (which don't think case) - don't know how update values within loop.

what's happening loop running instantly (counting 10,000 takes practically no time @ all). , i'd expect compiler optimize away loop unless use counter further down.

if goal when event fires - call method want run when completes within event itself. there isn't need loop. attempting "block" code until event fires/completes? wouldn't since it's not needed - continue rest of code called event itself.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -