Send Data Parallaly to Clients
-
Hi, I have written a publish service in WCF which publishes some data to the clients who have subscribed to the particular topic. For that I am retrieving the list of clients from the database and sending data to the clients. But the problem here is it is sending data serially. I mean according to the order in which the clients are saved in the database. For example client1 receives message at 12.30.41 and client 200 receives message at 12.31.55. Is there any way I can send the data at one shot? Here is the code: static void Publish(T[] subscribers,bool closeSubscribers, string methodName, params object[] args) { WaitCallback fire = delegate(object subscriber) { Invoke(subscriber as T,methodName,args); if(closeSubscribers) { using(subscriber as IDisposable) {} } }; Action queueUp = delegate(T subscriber) { ThreadPool.QueueUserWorkItem(fire,subscriber); }; Array.ForEach(subscribers,queueUp); } static void Invoke(T subscriber,string methodName,object[] args) { Type type = typeof(T); MethodInfo methodInfo = type.GetMethod(methodName); try { methodInfo.Invoke(subscriber,args); } catch {} } Please help.
-
Hi, I have written a publish service in WCF which publishes some data to the clients who have subscribed to the particular topic. For that I am retrieving the list of clients from the database and sending data to the clients. But the problem here is it is sending data serially. I mean according to the order in which the clients are saved in the database. For example client1 receives message at 12.30.41 and client 200 receives message at 12.31.55. Is there any way I can send the data at one shot? Here is the code: static void Publish(T[] subscribers,bool closeSubscribers, string methodName, params object[] args) { WaitCallback fire = delegate(object subscriber) { Invoke(subscriber as T,methodName,args); if(closeSubscribers) { using(subscriber as IDisposable) {} } }; Action queueUp = delegate(T subscriber) { ThreadPool.QueueUserWorkItem(fire,subscriber); }; Array.ForEach(subscribers,queueUp); } static void Invoke(T subscriber,string methodName,object[] args) { Type type = typeof(T); MethodInfo methodInfo = type.GetMethod(methodName); try { methodInfo.Invoke(subscriber,args); } catch {} } Please help.