私はマルチスレッドを掘り下げており、いくつかの優れたチュートリアルを見つけましたが、いくつかの質問が残っています.
1 つの関数を非同期で実行する方法を考えました (このチュートリアルを参照)。それをアーカイブするための 4 つの例があります。
しかし、私が開発しているアプリケーションでは、クラス全体を別のスレッドで実行したいと考えています。私はこのようなものを探しています:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace multithread_test
{
class Program
{
Program()
{ }
RunInBackground RIB;
void StartBackgroundWorker()
{
// how do I get RIB to run in the background?
RIB = new RunInBackground();
}
//somefunction to listen to the CallEventToUpdateGUI
}
//This class should run in a different thread than class Program
class RunInBackground
{
void RunInBackground()
{ }
void Function1()
{
//somefunction
}
void Function2()
{
// somefunction
}
void Function3()
{
Function1();
}
void CallEventToUpdateGUI()
{
//call a event to update gui
}
}