Tag: threadcontext

线程的ExecutionContext

ExecutionContext.SuppressFlow();的目的是什么? ? 在下面的代码中究竟被压制了什么? 我有这个测试代码…… protected void btnSubmit_Click(object sender, EventArgs e) { Thread[] th = new Thread[100]; Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(“en-GB”); AsyncFlowControl cntrl = ExecutionContext.SuppressFlow(); for (int i = 0; i < th.Length; i++) { th[i] = new Thread(new ParameterizedThreadStart(ThreadMethod)); th[i].Name = "Thread #" + (i+1).ToString(); th[i].Start((i+1).ToString()); } ExecutionContext.RestoreFlow(); foreach (Thread t in th) { t.Join(); […]