SoFunction
Updated on 2025-03-01

C# method of implementing operation between multiple threads based on delegate

This article describes the method of C# implementing multi-threaded operations based on delegate. Share it for your reference, as follows:

Sometimes we have to start multiple threads, and more often there may be a thread that will operate the properties in other threads.
However, threads are concurrent, and general calls cannot achieve our requirements.
So, we can use delegate here, the code is as follows

private delegate void DelegateInfo();
private delegate void DelegateIsEnd();
//This is a method of calling other threadsprivate void Dowork()
{
  // Determine whether Invoke is needed, if it is required when multi-threading  if ()
  {
    // Delegately call the program that writes the main thread control, pass the parameters and put them in the object array    (new DelegateInfo(LoadFile));
  }
  else
  {
    // If no delegate call is required, call it directly    ();
  }
  //=========== End of thread====================================  (new DelegateIsEnd(ISEnd));
}
private void ISEnd()
{
   = false;
  ();
  ();
}
private void LoadFile()
{
}
private WaitingForm wf = nu

I hope this article will be helpful to everyone's C# programming.