private void btnTruncateSelected_Click(object sender, EventArgs e)
        {
            AsyncTask<string,string, string> task = new AsyncTask<string,string,string>(this);
            TextBox LogTxt = null;

            Trunc.OnProgress += new TableTruncator.TableItemTruncateEventHandler(
                    delegate(string TableName, string Operation)
                    {
                        task.PublishProgress(string.Format("{0} -> {1}", Operation, TableName));
                    }
                );

            task.doInBackground = delegate(string[] param)
            {
                task.PublishProgress("Truncating tables...");

                Trunc.TruncateTable(param);

                return "Done";
            };

            task.onProgressUpdate = delegate(string[] param)
            {
                lblStatus.Text = param[0];
                LogTxt.AppendText(param[0] + "\r\n");
                LogTxt.SelectionStart = LogTxt.Text.Length;
            };

            task.onPostExecute = delegate(string result)
            {
                lblStatus.Text = result;
                LogTxt.AppendText(result + "\r\n");
                LogTxt.SelectionStart = LogTxt.Text.Length;

                LogTxt.AppendText("Disconnecting\r\n");

                if (chkShowScript.Checked)
                {
                    frmScriptViewer ScriptViewDlg = new frmScriptViewer(Trunc.ToString());
                    ScriptViewDlg.ShowDialog();
                }

                Trunc.Release();
            };

            Trunc.OnlyGenerateSQLScript = chkOnlyGenScript.Checked;
            LogTxt = PassProgressMode();

            task.Execute(GetCheckedTables());
        }
        private void frmApplication_Shown(object sender, EventArgs e)
        {
            lblName.Text = lblRelatedColumn.Text = lblRelatedTo.Text = lblRelationState.Text = "";

            Trunc = new TableTruncator(Connection);

            AsyncTask<string, string, string> task = new AsyncTask<string, string, string>(this);

            task.doInBackground = delegate(string[] param)
            {
                task.PublishProgress("Connecting to the SQL Server");
                Connection.Connect();
                task.PublishProgress("Gathering & inspecting tables...");
                Trunc.Initialize();
                return "Ready";
            };

            task.onProgressUpdate = delegate(string[] param)
            {
                lblStatus.Text = param[0];
            };

            task.onPostExecute = delegate(string result)
            {
                lblStatus.Text = result;

                List<string> Tables = Trunc.GetTables();

                TreeNode Root = tvTables.Nodes.Add(Setting.Database);

                foreach (string table in Tables)
                {
                    Root.Nodes.Add(table);
                }
            };

            task.Execute();
        }