示例#1
0
 void prepareGxAsync(ThreadExecuteTask threadExecute)
 {
     try
     {
         this.nextMinuteRedrawRect = this.prepareGxSync(ref this.gxNextMinute, this.nextMinute);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
     }
 }
示例#2
0
文件: MainForm.cs 项目: nakijun/adasg
            private void Refresh(ThreadExecuteTask threadExecute)
            {
                try
                {
                    DataRow[] childRows = this.mainForm.symbolDataSet.LocalizedSymbol.Select("CategoryId=" + this.currentCategoryId, "[Name] ASC");

                    ListViewItem[] items = new ListViewItem[childRows.Length];

                    for (int i = 0; i < items.Length; i++)
                    {
                        items[i]      = new ListViewItem();
                        items[i].Text = childRows[i]["Name"] as string;
                        items[i].Tag  = childRows[i];
                    }

                    this.mainForm.Invoke(this.mainForm.addSymbolListRangeDelegate, new object[] { items });

                    for (int i = 0; i < items.Length; i++)
                    {
                        //If an abort has been requested, we should quit
                        if (this.threadExecute.State == ThreadExecuteTask.ProcessingState.requestAbort)
                        {
                            threadExecute.setProcessingState(ThreadExecuteTask.ProcessingState.aborted);
                            Debug.WriteLine("aborted");
                            return;
                        }

                        DataRow row   = childRows[i];
                        byte[]  image = row["Image"] as byte[];
                        Image   img   = null;

                        if (image != null)
                        {
                            using (MemoryStream ms = new MemoryStream(image))
                            {
                                img = new Bitmap(ms);
                            }
                        }

                        this.mainForm.Invoke(this.mainForm.updateSymbolListItemDelegate, new object[] { items[i], img });
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }

                if (this.RefreshFinished != null)
                {
                    this.RefreshFinished();
                }
            }
示例#3
0
            private void prepareNextGx(int minutes)
            {
                this.nextMinute = minutes;

                if (this.threadExecute != null)
                {
                    this.threadExecute.Dispose();
                }

                //Package the class' method entry point up in a delegate
                ThreadExecuteTask.ExecuteMeOnAnotherThread delegateCallCode;
                delegateCallCode = new ThreadExecuteTask.ExecuteMeOnAnotherThread(this.prepareGxAsync);

                //Tell the thread to get going!
                this.threadExecute = new ThreadExecuteTask(delegateCallCode);
            }
示例#4
0
文件: MainForm.cs 项目: nakijun/adasg
            public void DoRefresh(int currentCategoryId)
            {
                if (this.threadExecute != null)
                {
                    this.threadExecute.Dispose();
                }

                this.currentCategoryId = currentCategoryId;

                //Package the class' method entry point up in a delegate
                ThreadExecuteTask.ExecuteMeOnAnotherThread delegateCallCode;
                delegateCallCode = new ThreadExecuteTask.ExecuteMeOnAnotherThread(this.Refresh);

                //Tell the thread to get going!
                this.threadExecute = new ThreadExecuteTask(delegateCallCode);
            }
示例#5
0
        public void Load(bool sync, int pageNumber)
        {
            if (this.lastLoadedPage != pageNumber)
            {
                firstRecordindex = pageNumber * this.countPerPage;

                if (sync)
                {
                    LoadData(null);
                }
                else
                {
                    //Package the class' method entry point up in a delegate
                    ThreadExecuteTask.ExecuteMeOnAnotherThread delegateCallCode;
                    delegateCallCode = new ThreadExecuteTask.ExecuteMeOnAnotherThread(this.LoadData);

                    //Tell the thread to get going!
                    threadExecute = new ThreadExecuteTask(delegateCallCode);
                }

                this.lastLoadedPage = pageNumber;
            }
        }
示例#6
0
        private void LoadData(ThreadExecuteTask threadExecute)
        {
            try
            {
                this.symbolList.Clear();

                for (int i = 0; i < countPerPage; i++)
                {
                    //If an abort has been requested, we should quit
                    if (threadExecute != null && threadExecute.State ==
                        ThreadExecuteTask.ProcessingState.requestAbort)
                    {
                        threadExecute.setProcessingState(ThreadExecuteTask.ProcessingState.aborted);
                        System.Windows.Forms.MessageBox.Show("aborted");
                        return;
                    }

                    bool ok;
                    if (i == 0)
                    {
                        ok = this.resultSet.ReadAbsolute(this.firstRecordindex);
                        Debug.Assert(ok, "Failed to seek to position: " + this.firstRecordindex);
                    }
                    else
                    {
                        ok = resultSet.Read();
                    }

                    if (ok)
                    {
                        SymbolInfo info = new SymbolInfo();

                        info.Id = resultSet.GetInt32(0);

                        object image = resultSet.GetValue(1);
                        using (MemoryStream ms = new MemoryStream(image as byte[]))
                        {
                            info.Image = ResizeImage(new Bitmap(ms), this.imageSize);
                        }

                        info.Sound = resultSet.GetValue(2) as byte[];

                        info.Text = resultSet.GetString(3);

                        symbolList.Add(info);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }

            if (this.DataLoaded != null)
            {
                this.DataLoaded();
            }
        }