Is it necessary to call EndInvoke in the callback from an EventHandler.BeginInvoke (C# .Net 3.5) -


i'm setting wcf client , server scenario needs reliable , scalable , part of i'm trying make multithreaded. admittedly don't have extensive multithreading experience.

on client, callback server (in case "onmessage") fires client-side event should passed off in background. have client's callbackbehavior concurrencymode set single (at least, now). in order reply callback, rather calling handler normal (either handler(sender, eventargs, or handler.invoke...) i'm calling handler.begininvoke.

everything works fine, in callback i'm wondering if need explicitly call endinvoke or if can nothing (here's lack of multithreading experience showing).

public void onmessage(message message) {     eventhandler<messageeventargs> handler = onservermessage;     if (handler != null)         handler.begininvoke(this, new messageeventargs(message), completehandler, handler); }  public void completehandler(iasyncresult result) {     ((eventhandler<messageeventargs>)result.asyncstate).endinvoke(result); } 

can replace completehandler direct reference handler.endinvoke, or empty method, or perhaps there more should doing?

also, @ moment, event subscriber blocks waiting on user input console. when application complete, either block waiting on database, or asynchronous bottom-to-top (so may not necessary, i'd still know).

yes have to. way find out if invoked method threw exception. , cleanup remoting state of call can garbage collected instead of letting linger 10 minutes.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -