public void IndexAsync(Guid id) { AsyncManager.OutstandingOperations.Increment(); Action asyncProductMaker = () => { Product p = new Product() { ProductId = id, Sku = "MyTestSku", CreatedOn = DateTime.Now, TimeStamp = id.ToByteArray() }; var goTo = DateTime.Now.AddMilliseconds(300); var time = DateTime.Now; while (time < goTo) { time = DateTime.Now; } AsyncManager.Parameters["p"] = p; AsyncManager.OutstandingOperations.Decrement(); }; asyncProductMaker.BeginInvoke(null, null); }
public IAsyncResult BeginGetProduct(string id, AsyncCallback asyncCallBack, object asyncState) { Guid gId = Guid.Parse(id); ProductAsyncResult asyncResult = new ProductAsyncResult(); asyncResult.AsyncState = asyncState; Action asyncProductMaker = () => { Product p = new Product() { ProductId = gId, Sku = "MyTestSku", CreatedOn = DateTime.Now, TimeStamp = gId.ToByteArray() }; var goTo = DateTime.Now.AddMilliseconds(300); var time = DateTime.Now; while (time < goTo) { time = DateTime.Now; } asyncResult.Data = p; asyncResult.IsCompleted = true; asyncCallBack(asyncResult); }; //Kick the method off asynchronously asyncProductMaker.BeginInvoke(null, null); return asyncResult; }
public JsonResult Index(Guid id) { Product p = new Product() { ProductId = id, Sku = "MyTestSku", CreatedOn = DateTime.Now, TimeStamp = id.ToByteArray() }; var goTo = DateTime.Now.AddMilliseconds(300); var time = DateTime.Now; while (time < goTo) { time = DateTime.Now; } return Json(p); }
public Product GetProduct(string id) { Guid gId = Guid.Parse(id); Product p = new Product() { ProductId = gId, Sku = "MyTestSku", CreatedOn = DateTime.Now, TimeStamp = gId.ToByteArray() }; var goTo = DateTime.Now.AddMilliseconds(300); var time = DateTime.Now; while (time < goTo) { time = DateTime.Now; } return p; }
public JsonResult IndexCompleted(Product p) { return Json(p); }