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); } } } } }