public Task <T> Enqueue <T>(Func <Task <T> > action, CancellationToken cancellationToken) { var workItem = new AsyncWorkItem <T>(action, cancellationToken); SynchronizationContext.Post(_SendOrPostWorkItem, workItem); return(workItem.Task); }
// Called by IStateClientManager::Set protected void SetAsync(String id, SessionStateItem item, byte[] buf, int length, bool inStorage) { AsyncWorkItem asyncWorkItem = new AsyncWorkItem(this, id, item, buf, length, inStorage, 0); WorkItem.PostInternal(new WorkItemCallback(asyncWorkItem.SetAsyncCallback)); }
public Task <T> Enqueue <T>(Func <Task <T> > action) { var workitem = new AsyncWorkItem <T>(action); _Context.Post(_ => workitem.Do(), null); return(workitem.Task); }
private void DoRealWork(object state) { AsyncWorkItem wi = (AsyncWorkItem)state; Debug.WriteLine(string.Format("Proccessing carried out on thread {0}", Thread.CurrentThread.ManagedThreadId)); wi._webMap.Context = wi._context; wi._context.Response.Clear(); string mime; using (Stream s = wi._webMap.Render(out mime)) { wi._context.Response.ContentType = mime; s.Position = 0; if (s.Length > 0) { using (BinaryReader br = new BinaryReader(s)) { using (Stream outStream = wi._context.Response.OutputStream) { outStream.Write(br.ReadBytes((int)s.Length), 0, (int)s.Length); } } } } wi._completed = true; wi._callback(this); }
public Task <T> Enqueue <T>(Func <Task <T> > action) { var workitem = new AsyncWorkItem <T>(action); _Context.Post(_SendOrPostWorkItem, workitem); return(workitem.Task); }
private Task <T> Enqueue <T>(AsyncWorkItem <T> workItem, CancellationToken cancellationToken) { return(Safe(() => { _TaskFactory.StartNew(workItem.Do, cancellationToken); return workItem.Task; })); }
private Task <T> Enqueue <T>(AsyncWorkItem <T> workItem) { return(Safe(() => { _TaskFactory.StartNew(workItem.Do); return workItem.Task; })); }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { Debug.WriteLine(string.Format("Request recieved on thread {0}", Thread.CurrentThread.ManagedThreadId)); SetCacheability(context.Response); AsyncWorkItem workItem = new AsyncWorkItem(this.WebMap, context, cb, extraData); workItem.DoWork(); return workItem; }
public Task <T> Enqueue <T>(Func <Task <T> > action) { return(Safe(() => { var workItem = new AsyncWorkItem <T>(action); _TaskFactory.StartNew(() => workItem.Do()); return workItem.Task; })); }
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { Debug.WriteLine(string.Format("Request recieved on thread {0}", Thread.CurrentThread.ManagedThreadId)); SetCacheability(context.Response); AsyncWorkItem workItem = new AsyncWorkItem(this.WebMap, context, cb, extraData); workItem.DoWork(); return(workItem); }
private Task <T> Enqueue <T>(AsyncWorkItem <T> workitem) { try { _TaskQueue.Enqueue(workitem); return(workitem.Task); } catch (Exception) { return(TaskBuilder <T> .Cancelled); } }
// Called by IStateClientManager::ResetTimeout protected void ResetTimeoutAsync(String id) { AsyncWorkItem asyncWorkItem = new AsyncWorkItem(this, id, null, null, 0, false, 0); WorkItem.PostInternal(new WorkItemCallback(asyncWorkItem.ResetTimeoutAsyncCallback)); }
// Called by IStateClientManager::Remove protected void RemoveAsync(String id, int lockCookie) { AsyncWorkItem asyncWorkItem = new AsyncWorkItem(this, id, null, null, 0, false, lockCookie); WorkItem.PostInternal(new WorkItemCallback(asyncWorkItem.RemoveAsyncCallback)); }