Getting started
In this page I will show you how to implement main files into your project for first use. It's very simple - take a look
In this page I will show you how to implement main files into your project for first use. It's very simple - take a look
BTM, Basic Thread Manager manages all kind of your task, long processes and time-undefined jobs running in C# apps in a very friendly and simple way.
For example, if you have method in your class and you know that execution of this method takes a long time (where time might be defined or not - not important). This is only one of many similar use cases.
BTM is library converts standard, synchronized methods (running the same thread with application) to asynchronized (running in separate threads). This get rid of "Application not responding" effect and give to our app new and fresh brief look.
For example, if we have a loop counting from 0 to 1 000 000, without BTM our app will be
hanged and we will see "Application not responding" which is not good. BTM creates new thread for each task.
Consequently main application has one thread and our loop has another one.
You can say once and for all goodbye to "Application not responding" screen!
BTM has been written in .NET 4.0 in Visual Studio 2010.
With this library you can:
First of all you can create new Visual Studio 2010 project and call it for example MyFirstAsyncApp like on the picture below
In Step 6 right click on References and choose Add Reference... option
In Step 8 choose Browse tab and navigate to source files in the Compiled folder. You must select all these files:
Now wherever you want to use this library you have to add using statement on the top of your file.
using BasicThreadManager;
this is mandatory main BTM library
using Microsoft.WindowsAPICodePack.Taskbar;
BTM is fully integrated with Microsoft Codec Pack (MSAPI) for nice
effects such as progressbar in taskbar icon - it is not mandatory, but if you decide to show progress in taskbar icon - it is.
and you have it! simple, right ?
We will be working here on previously created project MyFirstAsyncApp
Our main goal is to create really simple app that will be counting from 0 to 1 000 000. Maybe it is not very hard for our processors but without BTM it will freeze MyFirstAsyncApp until loop ends.
First, drag and drop button from left toolbar as shown below.
Next, click twice on the newly created button. It will be open code editor with click event.
Remember to add using statement.
Now you will see effect without and with BTM. Code without BTM
This code execution might be slow down your computer and hangs your application. You will need to wait until loop ends.
private void button1_Click(object sender, EventArgs e) { for (int i = 0; i < 1000000; i++) { Text = i.ToString(); } }
Code with BTM
private void button1_Click(object sender, EventArgs e) { var sgt = new BasicThreadWorker(); sgt.Maximum = 1000000; sgt.ThreadMethod = delegate { for (int i = 0; i < sgt.Maximum; i++) { sgt.ReportProgress(i); Console.WriteLine(i); } }; sgt.Start(); }
Result is here...
Dead simple, right ? :) But this is not the end... this is just begining...
Great! now you're ready to go to the next stage - details called Documentation
In this section you'll find many samples, code reviews, comments, BTM properties, BTM events, explanations and many more...