Tag Archives: threading

Use System.Threading.Timer to make a countdown timer in C#

The post Make a countdown timer in C# uses a Timer control to count down the time until some deadline. This example does something similar but it uses a Timer object from the System.Threading namespace. The basic idea is similar: … Continue reading

Posted in miscellany, system | Tagged , , , , , , , , , , , , | Leave a comment

Use BeginInvoke and callbacks to perform tasks asynchronously in C#

The example Use BeginInvoke and EndInvoke to perform tasks asynchronously in C# explains one way to call a method asynchronously so it can run on a separate core or CPU. In that example, the program calls BeginInvoke several times to … Continue reading

Posted in algorithms, graphics, image processing, threading | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Let a thread call a form’s methods in C#

When the user clicks the Start Thread button, this program runs a counter on a separate thread. Every second the counter updates the form’s Value variable. It then displays the thread’s number and the new Value in the ListBox at … Continue reading

Posted in algorithms, programs, system, threading | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Run threads with different priorities in C#

This example runs several different threads at different priorities. Each of the threads executes the following Counter class’s Run method. class Counter { // This counter’s number. public string Name; // Initializing constructor. public Counter(string name) { Name = name; … Continue reading

Posted in algorithms, programs, system, threading | Tagged , , , , , , , , , , , , , , , , , , , , | Leave a comment

Flush click events in C#

If a button starts a long task, you probably don’t want the user to be able to click the button again (or perhaps not anything in the application) until the task finishes. The following code shows a straightforward attempt to … Continue reading

Posted in API, controls, events, syntax, system, threading | Tagged , , , , , , , , , , , , , | 12 Comments

Use WMI to get the number of physical and logical processors in C#

This example shows how you can determine your computer’s number of processors, both physical and logical. Many computers these days contain multiple CPUs. Each CPU may contain multiple cores, processors that can execute instructions. Finally, some cores can execute multiple … Continue reading

Posted in performance, system, threading, WMI | Tagged , , , , , , , , , , , , , , , | Leave a comment

Use branch and bound with an initial heuristic to solve the partition problem in C#

The post Use exhaustive search to solve the partition problem in C# explains the partition problem and how you can use an exhaustive search to find solutions for it. The post Use branch and bound to solve the partition problem … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , | 1 Comment

Use branch and bound to solve the partition problem in C#

The post Use exhaustive search to solve the partition problem in C# explains the partition problem and how you can use an exhaustive search to find solutions for it. Unfortunately the number of possible solutions is enormous. If you are … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , | 1 Comment

Use exhaustive search to solve the partition problem in C#

In the partition problem, the goal is to divide a set of numbers into two subsets that have the same total. My favorite story for the partition problem is the “booty division problem.” Suppose you and a friend find a … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , | 4 Comments

Use a BackgroundWorker in C#

This example shows how to use a BackgroundWorker component to easily perform a task in the background while the program continues running. The example Use multiple threads to draw a graph in C# lets you perform an action in the … Continue reading

Posted in controls, programs, threading | Tagged , , , , , , , , , , | 6 Comments