protected IAsyncResult BeginCoreProcessRequest(AsyncCallback callback, object asyncState) { if (this.protocol.MethodAttribute.TransactionEnabled) { throw new InvalidOperationException(Res.GetString("WebAsyncTransaction")); } this.parameters = this.protocol.ReadParameters(); if (this.protocol.IsOneWay) { TraceMethod method = Tracing.On ? new TraceMethod(this, "OneWayAsyncInvoke", new object[0]) : null; if (Tracing.On) { Tracing.Information("TracePostWorkItemIn", new object[] { method }); } WorkItem.Post(new WorkItemCallback(this.OneWayAsyncInvoke)); if (Tracing.On) { Tracing.Information("TracePostWorkItemOut", new object[] { method }); } IAsyncResult ar = new CompletedAsyncResult(asyncState, true); if (callback != null) { callback(ar); } return ar; } return this.BeginInvoke(callback, asyncState); }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult asyncResult; try { PrepareContext(); protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke") : null; TraceMethod userMethod = Tracing.On ? new TraceMethod(protocol.Target, protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(protocol.MethodInfo.ToString(), caller, userMethod); } asyncResult = protocol.MethodInfo.BeginInvoke(protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) { Tracing.Enter(protocol.MethodInfo.ToString(), caller); } if (asyncResult == null) { throw new InvalidOperationException(Res.GetString(Res.WebNullAsyncResultInBegin)); } } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", e); } // save off the exception and throw it in EndCoreProcessRequest exception = e; asyncResult = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(asyncResult); } this.asyncBeginComplete.Set(); TraceFlush(); return(asyncResult); }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult result; try { this.PrepareContext(); this.protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke", new object[0]) : null; TraceMethod callDetails = Tracing.On ? new TraceMethod(this.protocol.Target, this.protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller, callDetails); } result = this.protocol.MethodInfo.BeginInvoke(this.protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller); } if (result == null) { throw new InvalidOperationException(Res.GetString("WebNullAsyncResultInBegin")); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", exception); } this.exception = exception; result = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(result); } this.asyncBeginComplete.Set(); TraceFlush(); return(result); }
protected IAsyncResult BeginCoreProcessRequest(AsyncCallback callback, object asyncState) { IAsyncResult asyncResult; if (protocol.MethodAttribute.TransactionEnabled) { throw new InvalidOperationException(Res.GetString(Res.WebAsyncTransaction)); } if (protocol.IsOneWay) { WorkItem.Post(new WorkItemCallback(this.OneWayAsyncInvoke)); asyncResult = new CompletedAsyncResult(asyncState, true); if (callback != null) { callback.Invoke(asyncResult); } } else { asyncResult = BeginInvoke(callback, asyncState); } return(asyncResult); }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult asyncResult; try { PrepareContext(); protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke") : null; TraceMethod userMethod = Tracing.On ? new TraceMethod(protocol.Target, protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) Tracing.Enter(protocol.MethodInfo.ToString(), caller, userMethod); asyncResult = protocol.MethodInfo.BeginInvoke(protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) Tracing.Enter(protocol.MethodInfo.ToString(), caller); if (asyncResult == null) throw new InvalidOperationException(Res.GetString(Res.WebNullAsyncResultInBegin)); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (Tracing.On) Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", e); // save off the exception and throw it in EndCoreProcessRequest exception = e; asyncResult = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(asyncResult); } this.asyncBeginComplete.Set(); TraceFlush(); return asyncResult; }
protected IAsyncResult BeginCoreProcessRequest(AsyncCallback callback, object asyncState) { IAsyncResult asyncResult; if (protocol.MethodAttribute.TransactionEnabled) throw new InvalidOperationException(Res.GetString(Res.WebAsyncTransaction)); parameters = protocol.ReadParameters(); if (protocol.IsOneWay) { TraceMethod callbackMethod = Tracing.On ? new TraceMethod(this, "OneWayAsyncInvoke") : null; if (Tracing.On) Tracing.Information(Res.TracePostWorkItemIn, callbackMethod); WorkItem.Post(new WorkItemCallback(this.OneWayAsyncInvoke)); if (Tracing.On) Tracing.Information(Res.TracePostWorkItemOut, callbackMethod); asyncResult = new CompletedAsyncResult(asyncState, true); if (callback != null) callback(asyncResult); } else asyncResult = BeginInvoke(callback, asyncState); return asyncResult; }
private IAsyncResult BeginInvoke(AsyncCallback callback, object asyncState) { IAsyncResult result; try { this.PrepareContext(); this.protocol.CreateServerInstance(); this.asyncCallback = callback; TraceMethod caller = Tracing.On ? new TraceMethod(this, "BeginInvoke", new object[0]) : null; TraceMethod callDetails = Tracing.On ? new TraceMethod(this.protocol.Target, this.protocol.MethodInfo.Name, this.parameters) : null; if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller, callDetails); } result = this.protocol.MethodInfo.BeginInvoke(this.protocol.Target, this.parameters, new AsyncCallback(this.Callback), asyncState); if (Tracing.On) { Tracing.Enter(this.protocol.MethodInfo.ToString(), caller); } if (result == null) { throw new InvalidOperationException(Res.GetString("WebNullAsyncResultInBegin")); } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (Tracing.On) { Tracing.ExceptionCatch(TraceEventType.Error, this, "BeginInvoke", exception); } this.exception = exception; result = new CompletedAsyncResult(asyncState, true); this.asyncCallback = callback; this.DoCallback(result); } this.asyncBeginComplete.Set(); TraceFlush(); return result; }