Is using Thread.Abort() and handling ThreadAbortException in .NET safe practice?

前端 未结 7 1012
执念已碎
执念已碎 2020-12-10 06:26

I need to develop a multithreaded Azure worker role in C# - create multiple threads, feed requests to them, each request might require some very long time to process (not my

7条回答
  •  半阙折子戏
    2020-12-10 07:19

    Please get simple idea from here as for your requirement, check thead isalive property, then abort your thread.............................................................

            ThreadStart th = new ThreadStart(CheckValue);
            System.Threading.Thread th1 = new Thread(th);
    
           if(taskStatusComleted)
          { 
            if (th1.IsAlive)
            {
                th1.Abort();
            }
          }
    

    private void CheckValue() { //my method.... }

提交回复
热议问题