Example #1
0
        private void LuceneBuild_Load(object sender, EventArgs e)
        {
            float size = DBInit.GetDBSize();

            Size_Label.Text       = $"{size.ToString()}MB";
            Finish_Label.Text     = StopWatchHelper.formatDuring(0);
            Lucenepath_Label.Text = StaticConst.LucenePath;
        }
Example #2
0
        /// <summary>
        /// Stops the the stopwatch
        /// </summary>
        public static void StopTimeMeasure()
        {
            try
            {
                lastElapsedTime = StopWatchHelper.Stop(lastTimerId);
            }
            catch (Exception counterManagementException)
            {
                MethodBase methodBase = MethodBase.GetCurrentMethod();
                Warn(methodBase.DeclaringType.Name, methodBase.Name, "Unable to stop time measure", counterManagementException);

                // Reset the last elapsed time value to avoid to use it in nexxt log attempt.
                ResetLastElapsedTime();
            }
        }
Example #3
0
    // Use this for initialization
    void Start()
    {
        this.swh = new StopWatchHelper();

        // Initializing Rayhit and registering the event listeners.
        // FIXME: Needs to fixed, it registers the hit too fast. Should be simple
        rayhit = gameObject.AddComponent(typeof(RayHit)) as RayHit;
        rayhit.StartHitEvent   += StartUseCase;
        rayhit.EnemyHitEvent   += SourceFound;
        rayhit.RestartHitEvent += RestartUseCase;

        // Initialize enemies, testcases and start the program by loading the next case
        enemyInitService.InitializeEnemyList(enemy);
        InitTestCases();
        LoadNextTestCase();
    }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            Stopwatch sw = new Stopwatch();

            sw.Start();

            CommodityIndexBuildWorker worker = new CommodityIndexBuildWorker();

            worker.ValueChanged += (argObj, argEvent) =>
            {
                ActInvoker(() =>
                {
                    progressBar1.Value = argEvent.Value;
                    Finish_Label.Text  = StopWatchHelper.formatDuring(sw.ElapsedMilliseconds);
                });
            };

            worker.TaskError += (argObj, argEvent) =>
            {
                ActInvoker(() =>
                {
                    FormHelper.Show("索引建立失败:" + argEvent.Value);
                    sw.Stop();
                    button1.Enabled = true;
                });
            };

            worker.TaskComplate += (argObj, argEvent) =>
            {
                ActInvoker(() =>
                {
                    FormHelper.Show("索引建立成功");
                    progressBar1.Value = 0;
                    sw.Stop();
                    button1.Enabled = true;
                });
            };
            worker.Build();
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            CommodityDAL.InitDb();

            long      allworkCount = 0;
            Stopwatch sw           = new Stopwatch();

            sw.Start();

            button1.Enabled = false;
            Task.Factory.StartNew(() =>
            {
                List <Task> taskList = new List <Task>();
                foreach (var category in categoryList)
                {
                    Task task = Task.Factory.StartNew(() =>
                    {
                        ActInvoker(() =>
                        {
                            dataGridView1.Rows[category.Index].Cells["State"].Value =
                                (int)ClawerEnum.TaskState.Doing;
                            dataGridView1.Rows[category.Index].Cells["StateText"].Value =
                                ClawerEnum.TaskState.Doing.GetDescription();
                        });

                        for (int i = 1; i <= category.PageCount; i++)
                        {
                            //取值
                            List <POCO_Commodity> cateList = CommodityAnalysis.GetData(category.Url, category.Id, i);
                            //处理
                            List <CommodityGroupInput> groupList = cateList.GroupBy(u => Convert.ToInt64(u.SUId) % StaticConst.CategorySheetCount).Select(u => new CommodityGroupInput
                            {
                                Id    = u.Key,
                                Units = u.OrderBy(p => p.SUId).ToList()
                            }).ToList();
                            //入库
                            _commodityService.InsertGroupBulk(groupList);
                        }
                    }).ContinueWith(t =>
                    {
                        allworkCount += category.PageCount;
                        ActInvoker(() =>
                        {
                            this.FinishCount.Text = allworkCount.ToString();
                            this.FinishHour.Text  = StopWatchHelper.formatDuring(sw.ElapsedMilliseconds);
                        });

                        ActInvoker(() =>
                        {
                            dataGridView1.Rows[category.Index].Cells["State"].Value =
                                (int)ClawerEnum.TaskState.Finshed;
                            dataGridView1.Rows[category.Index].Cells["StateText"].Value =
                                ClawerEnum.TaskState.Finshed.GetDescription();
                        });
                    });

                    taskList.Add(task);
                    if (taskList.Count > 20)
                    {
                        taskList = taskList.Where(t => !t.IsCompleted && !t.IsCanceled && !t.IsFaulted).ToList();
                        Task.WaitAny(taskList.ToArray());
                    }
                }

                Task.WhenAll(taskList.ToArray()).ContinueWith(t =>
                {
                    ActInvoker(() =>
                    {
                        button1.Enabled = true;
                        FormHelper.Show(true);
                        sw.Reset();
                    });
                });
            });
        }
Example #6
0
 /// <summary>
 /// Starts the stopwatch
 /// </summary>
 public static void StartTimeMeasure()
 {
     ResetLastElapsedTime();
     lastTimerId = StopWatchHelper.Start();
 }