I'm new to threading. While learning from WPF sample (A Wix Bootstrapper application), I've came across the use of System.Windows.Threading.Dispatcher in Run() method something like:
MyDispatcher = Dispatcher.CurrentDispatcher;
.
.
//rest of the code
.
Dispatcher.Run(); //This I believe invoke the app in a thread (plz correct me if I'm wrong).
Requirement: I'm trying to implement same in a Windows form application (Have to be for Net FW 2.0 for some reason), where I only have System.Threading namespace.
*Question:*How can I implement similar functionality like Dispatcher using System.Threading namespace?
Here's the sample code for .NET 2.0
// Called from any method
new Thread(() => { UpdateRequest(); }).Start();
// Background activity
private void UpdateRequest() {
UpdateUI("new text everytime" + DateTime.Now.ToString());
}
private void UpdateUI(string request)
{
if (control.InvokeRequired)
{
this.Invoke(new Delegate(UpdateUI), new object[] { request });
}
}
Update: Had accidentally used TPL as haven't used .NET 2.0 since long, replaced with native Threading