static async void ImagesGet(int count, DbAgent agent) { //Images_NewINstance DataSItem itm = new DataSItem(); itm.Schema = "general"; itm.Name = "Images_Get"; // itm.AddParam(new DataParam("@path", CustomSqlTypes.String)); itm.AddReturnParam(CustomSqlTypes.Int); // itm.FillPRocedureParamsFromSQLAgent(agent); // itm.Params.Add("@path",new DataParam()); Task compleateT = RunLimitedNumberAtATime(10, Enumerable.Range(1, count), async x => Task.Factory.StartNew(async() => { // itm.Params["@path"].Value = Guid.NewGuid().ToString(); ExecAsyncResult res = await itm.ExecuteDataReaderByRefAsync <Img>(agent); IBag <Img> images = res.Object as IBag <Img>; Console.WriteLine("Item Count : " + images.Objects.Count.ToString() + " " + res.ToString()); // Console.WriteLine(string.Format("Starting task {0}", x)); // await Task.Delay(1000); //Thread.Sleep(methodWait); // Console.WriteLine(string.Format("Finishing task {0}", x)); }, TaskCreationOptions.LongRunning)); await compleateT; }
static async Task ImagesGetAsyncMUltiple(DbAgent agent) { if (agent.ConnectionLevel == ConnectionLevel.AllInOne) { await agent.OpenConnectionAsync(); } DataSItem itm = new DataSItem(); itm.Schema = "general"; itm.Name = "Images_Get"; // itm.AddParam(new DataParam("@path", CustomSqlTypes.String)); itm.AddReturnParam(CustomSqlTypes.Int); // itm.FillPRocedureParamsFromSQLAgent(agent); // itm.Params.Add("@path",new DataParam()); for (int i = 0; i < 1000; i++) { ExecAsyncResult res1 = await itm.ExecuteDataReaderByRefAsync <Img>(agent); IBag <Img> images = res1.Object as IBag <Img>; Console.WriteLine("Item Count : " + images.Objects.Count.ToString() + " " + res1.ToString()); } if (agent.ConnectionLevel == ConnectionLevel.AllInOne) { agent.Dispose(); } }
static async void ImagesGetAsyncNewTest(DbAgent agent) { if (agent.ConnectionLevel == ConnectionLevel.AllInOne) { await agent.OpenConnectionAsync(); } DataSItem itm = new DataSItem(); itm.Schema = "general"; itm.Name = "Images_Get"; // itm.AddParam(new DataParam("@path", CustomSqlTypes.String)); itm.AddReturnParam(CustomSqlTypes.Int); // itm.FillPRocedureParamsFromSQLAgent(agent); // itm.Params.Add("@path",new DataParam()); List <Task <ExecAsyncResult> > _alltaskst = new List <Task <ExecAsyncResult> >(); for (int i = 0; i < 2; i++) { Task <ExecAsyncResult> t = itm.ExecuteDataReaderByRefAsync <Img>(agent); _alltaskst.Add(t); } while (_alltaskst.Count > 0) { Task <ExecAsyncResult> fintask = await Task.WhenAny(_alltaskst); _alltaskst.Remove(fintask); ExecAsyncResult result = await fintask; IBag <Img> images = result.Object as IBag <Img>; Console.WriteLine("Item Count : " + images.Objects.Count.ToString() + " " + result.ToString()); } // itm.Params["@path"].Value = Guid.NewGuid().ToString(); // Console.WriteLine(string.Format("Starting task {0}", x)); // await Task.Delay(1000); //Thread.Sleep(methodWait); // Console.WriteLine(string.Format("Finishing task {0}", x)); if (agent.ConnectionLevel == ConnectionLevel.AllInOne) { agent.Dispose(); } }
static async Task ReflectionGetAsync(DbAgent agent) { DataSItem itm = new DataSItem(); itm.Schema = "general"; itm.Name = "Images_Get"; // itm.AddParam(new DataParam("@path", CustomSqlTypes.String)); itm.AddReturnParam(CustomSqlTypes.Int); ExecAsyncResult res = await itm.ExecuteDataReaderByRefAsync <Img>(agent); IBag <Img> images = res.Object as IBag <Img>; Console.WriteLine("Item Count : " + images.Objects.Count.ToString() + " " + res.ToString()); }
static async Task ImagesGigImagesGET(int count, DbAgent agent) { DataSItem itm = new DataSItem(); itm.Schema = "general"; itm.Name = "Images_Get"; // itm.AddParam(new DataParam("@path", CustomSqlTypes.String)); itm.AddReturnParam(CustomSqlTypes.Int); // itm.FillPRocedureParamsFromSQLAgent(agent); // itm.Params.Add("@path",new DataParam()); Task compleateT = RunLimitedNumberAtATime(10, Enumerable.Range(1, count), async x => Task.Factory.StartNew(async() => { Console.WriteLine("Start! "); // itm.Params["@path"].Value = Guid.NewGuid().ToString(); ExecAsyncResult res = await itm.ExecuteDataReaderByRefAsync <Img>(agent); IBag <Img> images = res.Object as IBag <Img>; Console.WriteLine("Item Count : " + images.Objects.Count.ToString() + " " + res.ToString()); }, TaskCreationOptions.LongRunning)); await compleateT; }