Skip to main content
deleted 4 characters in body
Source Link
denied66
  • 644
  • 7
  • 19

Here's an example

bool _cancel = false; private void count() { _cancel = false; new System.Threading.Thread(delegate() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Here's an example

bool _cancel = false; private void count() { _cancel = false; new System.Threading.Thread(delegate() { for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 
deleted 137 characters in body
Source Link
denied66
  • 644
  • 7
  • 19

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Ideally you will want to put your method on a differnt thread than the UI one to avoid your UI freezing while your method is working.

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Ideally you will want to put your method on a differnt thread than the UI one to avoid your UI freezing while your method is working.

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 
added 108 characters in body
Source Link
denied66
  • 644
  • 7
  • 19

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false;   for (int i = 0; i < 100000; i++)   {   if (_cancel)   break;   Console.WriteLine(i);   } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Ideally you will want to put your method on a differnt thread than the UI one to avoid your UI freezing while your method is working.

Here's an example

bool _cancel = false; private void count() { _cancel = false; for (int i = 0; i < 100000; i++) { if (_cancel) break; Console.WriteLine(i); } } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Ideally you will want to put your method on a differnt thread than the UI one to avoid your UI freezing while your method is working.

Here's an example

bool _cancel = false; private void count() { new System.Threading.Thread(delegate() { _cancel = false;   for (int i = 0; i < 100000; i++)   {   if (_cancel)   break;   Console.WriteLine(i);   } }).Start(); } private void button1_Click(object sender, EventArgs e) { _cancel = true; } 

Ideally you will want to put your method on a differnt thread than the UI one to avoid your UI freezing while your method is working.

Source Link
denied66
  • 644
  • 7
  • 19
Loading