Пример #1
0
 //used as a new thread
 private static void SendMessage(Object obj)
 {
     try
     {
         SingleSubscriberInfoWithMessage s = (SingleSubscriberInfoWithMessage)obj;
         Client.SendMessage(s.Message, s.Ip, s.Port);
     }
     catch (Exception)
     {
     }
 }
Пример #2
0
        public static void SendToMultiple(SubscriberInfo info)
        {
            SingleSubscriberInfoWithMessage threadMessage;
            Thread t;

            // set message once outside the loop then change ip and port for each client
            foreach (SingleSubscriberInfo s in info.SubscriberList)
            {
                t = new Thread(new ParameterizedThreadStart(SendMessage));

                //this has to be new because of memory sharing
                threadMessage = new SingleSubscriberInfoWithMessage(s.Ip, s.Port, info.Message);

                t.Start(threadMessage);
            }
        }