private void ScriptThreadProc() { //WorkerThreadArguments arguments = (WorkerThreadArguments)threadArguments; CollationChanger collationChanger = new CollationChanger(); ScriptStepCollection script = null; SqlConnection connection = null; try { script = collationChanger.GenerateScript(workerThreadArguments.Callback, workerThreadArguments.Server, workerThreadArguments.UserId, workerThreadArguments.Password, workerThreadArguments.Database, workerThreadArguments.DropAllConstraints, workerThreadArguments.Collation, workerThreadArguments.Language, workerThreadArguments.SetSingleUser); if (script != null) { if (workerThreadArguments.ScriptOnly) { BeginInvoke(new ScriptCompleteCallback(ScriptComplete), new object[] { script }); } else { connection = new SqlConnection(Utils.ConnectionString(workerThreadArguments.Server, workerThreadArguments.UserId, workerThreadArguments.Password)); connection.Open(); script.Execute(connection, workerThreadArguments.Callback); BeginInvoke(new ExecuteCompleteCallback(ExecuteComplete)); } } else { BeginInvoke(new ScriptCompleteCallback(ScriptComplete), new object[] { null }); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { BeginInvoke(new ScriptCompleteErrorCallback(ScriptComplete), new object[] { ex }); } finally { if (connection != null) { connection.Dispose(); } } lock (this) { workerThread = null; } }
private void ScriptThreadProc() { //WorkerThreadArguments arguments = (WorkerThreadArguments)threadArguments; CollationChanger collationChanger = new CollationChanger(); ScriptStepCollection script = null; SqlConnection connection = null; try { script = collationChanger.GenerateScript(workerThreadArguments.Callback, workerThreadArguments.Server, workerThreadArguments.UserId, workerThreadArguments.Password, workerThreadArguments.Database, workerThreadArguments.DropAllConstraints, workerThreadArguments.Collation, workerThreadArguments.Language, workerThreadArguments.SetSingleUser); if (workerThreadArguments.ScriptOnly) { BeginInvoke(new ScriptCompleteCallback(ScriptComplete), new object[] {script}); } else { connection = new SqlConnection(Utils.ConnectionString(workerThreadArguments.Server, workerThreadArguments.UserId, workerThreadArguments.Password)); connection.Open(); script.Execute(connection, workerThreadArguments.Callback); BeginInvoke(new ExecuteCompleteCallback(ExecuteComplete)); } } catch (ThreadAbortException) { throw; } catch (Exception ex) { BeginInvoke(new ScriptCompleteErrorCallback(ScriptComplete), new object[] { ex}); } finally { if (connection != null) connection.Dispose(); } lock (this) { workerThread = null; } }