internal void UDPReciever() { try { timerforchecklogin = new System.Timers.Timer(); timerforchecklogin.Interval = 30000; timerforchecklogin.Start(); timerforchecklogin.Elapsed += timerforchecklogin_Elapsed; Task.Factory.StartNew(() => { while (true) { // string address = subscriber.Receive (Encoding.Unicode); // byte[] buffer = new byte[512]; // int bufferSize = subscriber.Receive (buffer); var buffer = subscriber.Receive(); if (buffer == null) { this.OnDataStatusChange.Raise(OnDataStatusChange, OnDataStatusChange.CreateReadOnlyArgs("STOP")); continue; } //Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(4).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); long TokenName = BitConverter.ToInt64(buffer, 0); Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); //if (Global.Instance.Data_With_Nano.ContainsKey(TokenName)) //{ // switch(Global.Instance.Data_With_Nano[TokenName]) // { // case ClassType.MARKETWTCH: // Data = (INTERACTIVE_ONLY_MBP)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(INTERACTIVE_ONLY_MBP)); // OnDataChange.Raise(OnDataChange, OnDataChange.CreateReadOnlyArgs(Data)); // break; // case ClassType.SPREAD: // SpreadData_7211 = (MS_SPD_MKT_INFO_7211)DataPacket.RawDeserialize(buffer.Skip(8).ToArray(), typeof(MS_SPD_MKT_INFO_7211)); // OnSpreadDataChange.Raise(OnSpreadDataChange, OnSpreadDataChange.CreateReadOnlyArgs(SpreadData_7211)); // break; // } //} } }); } catch (OperationCanceledException e) { Console.WriteLine("Cancellation invoked"); } catch (AggregateException e) { Console.WriteLine("Some unexpected exception "); } catch (Exception Ex) { Console.WriteLine("Exception Raised " + Ex.StackTrace); } }