Exemplo n.º 1
0
		private void cmdFind_Click(object sender, EventArgs e)
		{
			// Get the search range.
			int from, to;
            if (!Int32.TryParse(txtFrom.Text, out from))
            {
                MessageBox.Show("Invalid From value.");
                return;
            }
            if (!Int32.TryParse(txtTo.Text, out to))
            {
                MessageBox.Show("Invalid To value.");
                return;
            }

			// Create the task.
			EratosthenesTask task = new EratosthenesTask(from, to);

			// Add the task to the grid.
			ListViewItem item = new ListViewItem(task.ID.ToString());
			item.SubItems.Add(from.ToString() + " to " + to.ToString());
			item.SubItems.Add("Queued");
			listTasks.Items.Add(item);

			// Enqueue the task.
			taskManager.EnqueueTask(task);
		}
Exemplo n.º 2
0
        private void cmdNewSearch_Click(object sender, EventArgs e)
        {
            AsyncTestQuery search = new AsyncTestQuery();
            if (search.ShowDialog() == DialogResult.OK)
            {
                // Start the new search.
				EratosthenesTask worker = new EratosthenesTask(search.From, search.To);
				worker.Completed += new FindPrimesCompletedEventHandler(WorkerCompleted);
                lock (workers)
                {
                    workers.Add(worker);
                    statusPanel.Text = String.Format("Currently running {0} tasks.", workers.Count);
                }
                worker.Start();
            }
            search.Dispose();
        }
 public WorkerCompletedEventArgs(EratosthenesTask task)
 {
     PrimeList = task.GetResultOfLastTask();
     id        = task.ID;
 }
Exemplo n.º 4
0
			public WorkerCompletedEventArgs(EratosthenesTask task)
			{
				PrimeList = task.GetResultOfLastTask();
				id = task.ID;
			}