public void SubmitResult(ResultBase result) { lock (this) { if (_state != State.CommandSent) { // do nothing InvokeTrace("Result from client ignored - _state is {0}", _state); return; } if (result == null) { // do nothing InvokeTrace("Result from client ignored - null result"); return; } if (!IsCurrentCommand(result.Id)) { // do nothing InvokeTrace("Result from client ignored - not current command id"); return; } if (Verbose) InvokeTrace("Result from client received - processing..."); InvokeCallbackAndClear(result); } }
private void InvokeCallbackAndClear(ResultBase result) { lock(this) { if (_resultCallback != null) { // invoke callback on a separate thread // note that we copy callback to a local variable (to ensure its not null when the thread is invoked) var callback = _resultCallback; ThreadPool.QueueUserWorkItem((ignored) => callback(result)); } Clear(); } }
private static void LogFailedMessage(ResultBase toReturn) { var failedResultBase = toReturn as FailedResultBase; if (failedResultBase != null) { Console.WriteLine("WCF command messages ->: {0}", failedResultBase.FailureText); } }