void IMessageProcessor.Start() { _messageQueue.Open(); ThreadingHelper .Thread(() => CultureInfo.InvariantCulture.DoInCulture(() => { while (!_messageQueue.IsClosed) { try { MessageItem item; if (!TryDequeue(out item)) { break; } _newMessage.SafeInvoke(item.Item1, item.Item2); } catch (Exception ex) { _errorHandler(ex); } } _stopped.SafeInvoke(); })) .Name("{0}. Messages thread.".Put(Name)) //.Culture(CultureInfo.InvariantCulture) .Launch(); }
/// <summary> /// Open channel. /// </summary> public void Open() { _messageQueue.Open(); ThreadingHelper .Thread(() => CultureInfo.InvariantCulture.DoInCulture(() => { while (!_messageQueue.IsClosed) { try { KeyValuePair <DateTimeOffset, Message> pair; if (!_messageQueue.TryDequeue(out pair)) { break; } //if (!(message is TimeMessage) && message.GetType().Name != "BasketMessage") // Console.WriteLine("<< ({0}) {1}", System.Threading.Thread.CurrentThread.Name, message); _msgStat.Remove(pair.Value); NewOutMessage.SafeInvoke(pair.Value); } catch (Exception ex) { _errorHandler(ex); } } Closed.SafeInvoke(); })) .Name("{0} channel thread.".Put(Name)) //.Culture(CultureInfo.InvariantCulture) .Launch(); }
public void Open() { _messageQueue.Open(); ThreadingHelper .Thread(() => CultureInfo.InvariantCulture.DoInCulture(() => { while (!_messageQueue.IsClosed) { try { var sended = _historyMessageAdapter.SendOutMessage(); KeyValuePair <DateTimeOffset, Message> pair; if (!_messageQueue.TryDequeue(out pair, true, !sended)) { if (!sended) { break; } } else { NewOutMessage.SafeInvoke(pair.Value); } } catch (Exception ex) { _errorHandler(ex); } } })) .Name("History emulation channel thread.") .Launch(); }