public void Dispatch(RawMessage message, Func <RawMessage, string> dispatchCallback) { IMessageProcessor processor = processors[message.messageType]; if (processor != null) { Task.Factory.StartNew(() => { JsonCommand ret = processor.Handle(message); if (dispatchCallback != null && ret != null && ret.Directive != CommandDirective.NONE) { RawMessage retRaw = MessageUtils.BuildJsonMessage(message.clientNo, ret); string callbackRet = dispatchCallback.Invoke(retRaw); } }); } else { logger.ErrorFormat("no processor for type#{0}, text#{1}.", message.messageType, message.bodyText); } }