/// <summary> /// HTTP 처리기에 대한 비동기 호출을 시작합니다. /// </summary> /// <returns> /// 프로세스 상태에 대한 정보가 들어 있는 <see cref="T:System.IAsyncResult"/>입니다. /// </returns> /// <param name="context"> /// Request, Response, Session, Server 등과 같이 HTTP 요청을 처리하는 데 사용되는 내장 서버 개체에 대한 참조를 제공하는 <see cref="T:System.Web.HttpContext"/> 개체입니다. /// </param> /// <param name="cb">비동기 메서드 호출이 완료될 때 호출할 <see cref="T:System.AsyncCallback"/>입니다.<paramref name="cb"/>이 null이면 대리자가 호출되지 않습니다.</param> /// <param name="extraData">요청을 처리하는 데 필요한 모든 추가 데이터입니다.</param> public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { if(IsDebugEnabled) log.Debug("비동기 방식의 HttpHandler의 처리를 시작합니다... context=[{0}], cb=[{1}], extraData=[{2}]", context, cb, extraData); _asyncProcess = new AsyncProcessDelegate(DoProcessRequest); return _asyncProcess.BeginInvoke(context, cb, extraData); }
public static AsyncProcessDelegate NullMiddlewareAsyncMethod(AsyncProcessDelegate asyncNext) { AsyncProcessDelegate retval; Console.WriteLine("{1} (before GetMiddlewareChain): '{0}'", nameof(NullProcessor), nameof(NullMiddlewareAsyncMethod)); retval = AsyncProcessorClosure.GetMiddlewareChain(NullProcessorAsyncMethod, asyncNext); Console.WriteLine("{1} (after GetMiddlewareChain): '{0}'", nameof(NullProcessor), nameof(NullMiddlewareAsyncMethod)); return(retval); }
/// <summary> /// HTTP 처리기에 대한 비동기 호출을 시작합니다. /// </summary> /// <returns> /// 프로세스 상태에 대한 정보가 들어 있는 <see cref="T:System.IAsyncResult"/>입니다. /// </returns> /// <param name="context"> /// Request, Response, Session, Server 등과 같이 HTTP 요청을 처리하는 데 사용되는 내장 서버 개체에 대한 참조를 제공하는 <see cref="T:System.Web.HttpContext"/> 개체입니다. /// </param> /// <param name="cb">비동기 메서드 호출이 완료될 때 호출할 <see cref="T:System.AsyncCallback"/>입니다.<paramref name="cb"/>이 null이면 대리자가 호출되지 않습니다.</param> /// <param name="extraData">요청을 처리하는 데 필요한 모든 추가 데이터입니다.</param> public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { if (IsDebugEnabled) { log.Debug("비동기 방식의 HttpHandler의 처리를 시작합니다... context=[{0}], cb=[{1}], extraData=[{2}]", context, cb, extraData); } _asyncProcess = new AsyncProcessDelegate(DoProcessRequest); return(_asyncProcess.BeginInvoke(context, cb, extraData)); }
public AsyncProcessDelegate BuildAsync() { AsyncProcessDelegate process = async(asyncContext, configuration, asyncChannel, cancellationToken) => await Task.FromResult(asyncChannel); // simply return original channel unmodified foreach (Func <AsyncProcessDelegate, AsyncProcessDelegate> component in this.Components.Reverse()) { process = component(process); } return(process); }
/// <summary> /// Queues a method for execution in a non-GUI thread and indicates on the form that an asynchronous operation is occuring. /// </summary> /// <param name="callback"></param> protected void RunAsyncOperation(AsyncProcessDelegate callback) { WaitCallback d = delegate(object not_used) { try { callback.Invoke(); } finally { this.Invoke(new SafeWinFormsThreadDelegate(EndAsyncIndication)); } }; BeginAsyncIndication(); ThreadPool.QueueUserWorkItem(d); }
private void button3_Click(object sender, EventArgs e) { AsyncProcessDelegate d = delegate() { System.Threading.Thread.Sleep(3000); }; AsyncProcessDelegate db = delegate() { System.Threading.Thread.Sleep(9000); }; RunAsyncOperation(d); RunAsyncOperation(d); RunAsyncOperation(db); }
private void button1_Click(object sender, EventArgs e) { OldText = button1.Text; button1.Enabled = false; button1.Text = "Working..."; TestId = 1;// Get this from the main form AsyncProcessDelegate d = delegate() { GetQuestions(this); //ThreadPool.QueueUserWorkItem(new WaitCallback(GetQuestions), this); }; RunAsyncOperation(d); }
private AsyncProcessorClosure(AsyncProcessToNextDelegate asyncProcessToNext, AsyncProcessDelegate asyncNext) { if ((object)asyncProcessToNext == null) { throw new ArgumentNullException(nameof(asyncProcessToNext)); } if ((object)asyncNext == null) { throw new ArgumentNullException(nameof(asyncNext)); } this.asyncProcessToNext = asyncProcessToNext; this.asyncNext = asyncNext; }
private static async Task <IAsyncChannel> NullProcessorAsyncMethod(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken) { IAsyncChannel newAsyncChannel; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } await StdOut.WriteLineAsync(string.Format("{1} (before next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorAsyncMethod))); if ((object)asyncNext != null) { newAsyncChannel = await asyncNext(asyncContext, configuration, asyncChannel, cancellationToken); } else { newAsyncChannel = asyncChannel; } await StdOut.WriteLineAsync(string.Format("{1} (after next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorAsyncMethod))); return(newAsyncChannel); }
/// <summary> /// Queues a method for execution in a non-GUI thread and indicates on the form that an asynchronous operation is occuring. /// </summary> /// <param name="callback"></param> protected void RunAsyncOperation(AsyncProcessDelegate callback) { WaitCallback d = delegate(object not_used) { try { callback.Invoke(); } finally { this.Invoke(new SafeWinFormsThreadDelegate(EndAsyncIndication)); } }; BeginAsyncIndication(); ThreadPool.QueueUserWorkItem(d); }
protected abstract Task <IAsyncChannel> ProcessAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken);
public Task <IAsyncChannel> ProcessAsync(IAsyncContext asyncContext, RecordConfiguration configuration, IAsyncChannel asyncChannel, AsyncProcessDelegate asyncNext, CancellationToken cancellationToken) { Task <IAsyncChannel> newAsyncChannelTask; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if ((object)asyncChannel == null) { throw new ArgumentNullException(nameof(asyncChannel)); } newAsyncChannelTask = this.ProcessAsyncInternal(asyncContext, configuration, asyncChannel, asyncNext, cancellationToken); return(newAsyncChannelTask); }
public static AsyncProcessDelegate GetMiddlewareChain(AsyncProcessToNextDelegate asyncProcessToNext, AsyncProcessDelegate asyncNext) { if ((object)asyncProcessToNext == null) { throw new ArgumentNullException(nameof(asyncProcessToNext)); } if ((object)asyncNext == null) { throw new ArgumentNullException(nameof(asyncNext)); } return(new AsyncProcessorClosure(asyncProcessToNext, asyncNext).TransformAsync); }