/// <summary> /// Event invocator for <see cref="objectReceived"/> /// </summary> /// <param name="e">Event arguments</param> protected virtual void onObjectReceived(ObjectReceivedEventArgs e) { bool first = !Interlocked.Exchange(ref _firstReceived, new Tuple <bool>(true)).Item1; if (first && !_authDone.IsSet) { _authDone.Set(); var test = e.Object; return; } else { _authDone.Wait(); EventHandler <ObjectReceivedEventArgs> handler = objectReceived; if (handler != null) { handler(this, e); } } }
/// <summary> /// Handles the objectReceived event of the client. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ObjectReceivedEventArgs"/> instance containing the event data.</param> private void _client_objectReceived(object sender, ObjectReceivedEventArgs e) { if (_awaitResult == null) { if (!_results.TryDequeue(out _awaitResult)) { _awaitResult = null; } } if (_awaitResult != null) { _awaitResult.result = e.Object; if (_awaitResult.allResultsAcquired) { _awaitResult.waiter.Set(); _awaitResult = null; } } _resultConsumed.Reset(); }
/// <summary> /// Event invocator for <see cref="objectReceived"/> /// </summary> /// <param name="e">Event arguments</param> protected virtual void onObjectReceived(ObjectReceivedEventArgs e) { bool first = !Interlocked.Exchange(ref _firstReceived, new Tuple<bool>(true)).Item1; if (first && !_authDone.IsSet) { _authDone.Set(); var test = e.Object; return; } else { _authDone.Wait(); EventHandler<ObjectReceivedEventArgs> handler = objectReceived; if (handler != null) handler(this, e); } }
/// <summary> /// Handles the objectReceived event of the client. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ObjectReceivedEventArgs"/> instance containing the event data.</param> private void _client_objectReceived(object sender, ObjectReceivedEventArgs e) { if (_awaitResult == null) { if (!_results.TryDequeue(out _awaitResult)) _awaitResult = null; } if (_awaitResult != null) { _awaitResult.result = e.Object; if (_awaitResult.allResultsAcquired) { _awaitResult.waiter.Set(); _awaitResult = null; } } _resultConsumed.Reset(); }