Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取后台工作线程id_C#_Wpf_Multithreading_Backgroundworker - Fatal编程技术网

C# 如何获取后台工作线程id

C# 如何获取后台工作线程id,c#,wpf,multithreading,backgroundworker,C#,Wpf,Multithreading,Backgroundworker,我想确定我的后台工作线程id 当我调用RunWorkerAsync()方法时,它会创建一个工作线程。当然,我可以从Process.GetCurrentProcess().threads方法获得一个包含所有线程的列表,但是这个列表有很多线程id,我不知道如何识别我的工作线程id 当我调用RunWorkerAsync()方法时,是否可能立即获得该线程id 像这样 谢谢大家! 你可以这样做 int threadId = System.Threading.Thread.CurrentThread.Ma

我想确定我的后台工作线程id

当我调用
RunWorkerAsync()
方法时,它会创建一个工作线程。当然,我可以从
Process.GetCurrentProcess().threads
方法获得一个包含所有线程的列表,但是这个列表有很多线程id,我不知道如何识别我的工作线程id

当我调用
RunWorkerAsync()
方法时,是否可能立即获得该线程id

像这样


谢谢大家!

你可以这样做

int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
如果您指定所有线程所在的当前进程id

int processId = System.Diagnostics.GetCurrentProcess().Id;