本文整理汇总了C#中Thread.JoinAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Thread.JoinAsync方法的具体用法?C# Thread.JoinAsync怎么用?C# Thread.JoinAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread.JoinAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
/// <summary>
/// This is a javascript application.
/// </summary>
/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
public Application(IApp page)
{
// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201406/20140628
// X:\jsc.svn\examples\java\ParallelForEachExperiment\ParallelForEachExperiment\ApplicationControl.cs
var t = new Thread(
new ParameterizedThreadStart(
o =>
{
// we have a local copy of the object.
var oo = o as XData;
// all member access methods should be non blocking
// if they need to span across thread boundaries
Console.WriteLine("working on the other thread");
// update local, then update parent memory
oo.goo += ", from thread " + new { Thread.CurrentThread.ManagedThreadId };
// or should the fields be transferable dictionary?
// we could just send the data part back now
}
)
);
var ooo = new XData { goo = "goo1 " + new { Thread.CurrentThread.ManagedThreadId } };
t.Start(
// we are sending in data/objects
ooo
);
t.JoinAsync(
delegate
{
// 0:18ms working on the other thread
//0:122ms { goo = from thread }
//Console.WriteLine(new { ooo.goo });
// { goo = goo1 { ManagedThreadId = 1 }, from thread { ManagedThreadId = 1 } }
new IHTMLPre
{
new { ooo.goo }
}.AttachToDocument();
}
);
}