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 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 Product EndGetProduct(IAsyncResult result) { ProductAsyncResult pResult = (ProductAsyncResult)result; return(pResult.Data); }
public Models.Product EndGetProductById(IAsyncResult result) { ProductAsyncResult pResult = (ProductAsyncResult)result; return(pResult.Data); }