Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.SqlClient;
- namespace Asynchronous_Console_App
- {
- class Program
- {
- static void Main(string[] args)
- {
- SqlDataAdapter dataAdapter = new SqlDataAdapter();
- SqlConnection con = new SqlConnection("Server=CHALAURI; Database=Students; Integrated Security=true; Asynchronous Processing = true;");
- string command = "UPDATE Students SET NUMBER = NUMBER+1; " + "WAITFOR DELAY '0:0:10'" + " UPDATE Students SET NUMBER = NUMBER+1";
- SqlCommand update = new SqlCommand(command, con);
- con.Open();
- IAsyncResult result = update.BeginExecuteNonQuery();
- while (!result.IsCompleted)
- {
- Console.WriteLine(DateTime.Now.ToLongTimeString());
- System.Threading.Thread.Sleep(2000);
- }
- update.EndExecuteNonQuery(result);
- con.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement