static async Task NewImagesViaAgent(DbAgent agent) { DataSItem itm = new DataSItem { // itm.Schema = "general"; Schema = "general", Name = "Images_NewINstance" }; itm.AddParam(new DataParam("@path", CustomSqlTypes.String, ParamDirection.Input, Guid.NewGuid().ToString())); itm.AddReturnParam(CustomSqlTypes.Int); // itm.Params["@path"].Value = Guid.NewGuid().ToString(); await agent.OpenConnectionAsync(); ExecAsyncResult res = await itm.ExecuteNonQueryAsync(agent); Console.WriteLine(res.ToString()); itm.Params["@path"].Value = Guid.NewGuid().ToString(); res = await itm.ExecuteNonQueryAsync(agent); Console.WriteLine(res.ToString()); agent.Dispose(); }
static async void NewImages(int count, DbAgent agent) { //Images_NewINstance DataSItem itm = new DataSItem(); // itm.Schema = "general"; itm.Schema = "dbo"; itm.Name = "Images_NewINstance"; 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.ExecuteNonQueryAsync(agent); Console.WriteLine(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; }
private async Task ExecuteNonQuery(DataSItem temp) { using (frmparamLoad load = new frmparamLoad(_selectedProcedure)) { if (load.ShowDialog() == DialogResult.OK) { if (load.Result != null) { _selectedProcedure = load.Result; lblStatues.Text = "Loading NonQuery procedure "; ExecAsyncResult result = await _selectedProcedure.ExecuteNonQueryAsync(_currentAgent); lblStatues.Text = "Done."; rTxtresult.AppendColorText(result.ToString(), Color.Blue); if (_selectedProcedure.HasOutputParam) { rTxtresult.AppendColorText("Output Params", Color.GreenYellow); foreach (DataParam dataParam in _selectedProcedure.OutputParams.Values) { rTxtresult.AppendColorText(dataParam.Name + " = " + dataParam.Value, Color.Green); } rTxtresult.AppendColorText(new string('-', 30), Color.GreenYellow); } } } } }
private async Task ExecuteDs(DataSItem temp) { using (frmparamLoad load = new frmparamLoad(temp)) { if (load.ShowDialog() == DialogResult.OK) { if (load.Result != null) { _selectedProcedure = load.Result; lblStatues.Text = "Loading dataSetExecution ..."; ExecAsyncResult result = await _selectedProcedure.ExecDataSetAsync(_currentAgent); lblStatues.Text = "Done."; rTxtresult.AppendColorText(result.ToString(), Color.Blue); DataSet rsSet = result.Object as DataSet; if (rsSet.Tables.Count > 0) { dataGridSet.DataSource = rsSet.Tables[0]; } if (_selectedProcedure.HasOutputParam) { rTxtresult.AppendColorText("Output Params", Color.GreenYellow); foreach (DataParam dataParam in _selectedProcedure.OutputParams.Values) { rTxtresult.AppendColorText(dataParam.Name + " = " + dataParam.Value, Color.Green); } rTxtresult.AppendColorText(new string('-', 30), Color.GreenYellow); } } } } }
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; }
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 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(); } }