DefconDotNet

deadlocks

Mar 8th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1.         public void Stuff()
  2.         {
  3.             bool succes = false;
  4.             int retryCount = 3;
  5.             using (SqlConnection connection = new SqlConnection(connectionString))
  6.             {
  7.                 connection.Open();
  8.                 while (retryCount > 0 && succes == false)
  9.                 {
  10.                     try
  11.                     {
  12.                         cmd setup stuff here..
  13.                        
  14.                         cmd.ExecuteNonQuery();
  15.                         succes = true;
  16.                     }
  17.                     catch (SqlException exception)
  18.                     {
  19.                         if (exception.Number != 1205)
  20.                         {
  21.                             throw;
  22.                         }
  23.                         Thread.Sleep(100);
  24.                         retryCount--;
  25.                         if (retryCount == 0) throw;
  26.                     }
  27.                 }
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment