当前位置: 首页>>代码示例>>C#>>正文


C# Thread.JoinAsync方法代码示例

本文整理汇总了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();

                }
            );


        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:59,代码来源:Application.cs


注:本文中的Thread.JoinAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。