Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            StockDownloadManager dm = new StockDownloadManager();

            dm.getLastUpdateDate();

            ThreadStart ts = new ThreadStart(dm.DownloadToLatest);
            Thread      t  = new Thread(ts);

            t.Start();
        }
Exemple #2
0
        private void button_SyncDatabase_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn.Text.Equals("Download Data"))
            {
                btn.Text = "Stop";
                Logger.setDebugMessageOnOff(checkBox_debug_message.Checked);

                download_manager = new StockDownloadManager();
                //db_manager = new DBManager();

                if (checkBox_check_all.Checked)
                {
                    download_manager.setCheckDownload();
                }

                StatusUpdateTimer          = new System.Timers.Timer();
                StatusUpdateTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
                // Set the Interval to 2 seconds (2000 milliseconds).
                StatusUpdateTimer.Interval = 200;
                StatusUpdateTimer.Enabled  = true;

                backgroundWorker1 = new BackgroundWorker();
                backgroundWorker1.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
                backgroundWorker1.DoWork                    += new DoWorkEventHandler(this.backgroundWorker1_DoWork);
                backgroundWorker1.ProgressChanged           += new ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
                backgroundWorker1.WorkerReportsProgress      = true;
                backgroundWorker1.WorkerSupportsCancellation = true;

                backgroundWorker1.RunWorkerAsync();
            }
            else
            {
                btn.Text = "Download Data";

                if (backgroundWorker1 != null)
                {
                    backgroundWorker1.CancelAsync();
                }
            }

            /*hreadStart ts = new ThreadStart(syncTask);
             * Thread t = new Thread(ts);
             * t.Start();*/
        }