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


C# Worker.DoWork方法代码示例

本文整理汇总了C#中Worker.DoWork方法的典型用法代码示例。如果您正苦于以下问题:C# Worker.DoWork方法的具体用法?C# Worker.DoWork怎么用?C# Worker.DoWork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Worker的用法示例。


在下文中一共展示了Worker.DoWork方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Worker worker = new Worker();

            //worker.BadDoWork();
            worker.DoWork();

            Console.ReadKey();
        }
开发者ID:kaplunov93,项目名称:MoreEffectiveCSharp,代码行数:9,代码来源:Item+15.cs

示例2: Execute

 public override bool Execute()
 {
     try
     {
         var worker = new Worker();
         worker.DoWork(this, this);
         return true;
     }
     catch (Exception exception)
     {
         Log.LogErrorFromException(exception);
         return false;
     }
 }
开发者ID:craignicol,项目名称:trello-release-notes,代码行数:14,代码来源:TrelloRelease.cs

示例3: ApiThread

        private void ApiThread()
        {
            // Start the Selfhosted WebAPI. Read the apiUrl from the config file
            var listenUrl = ConfigurationManager.AppSettings["ApiUrl"];
            Console.WriteLine("Launching WebAPI at " + listenUrl);
            // If this line generates an error, you can use the netsh command to allow the port to be listened on by non-administrators
            // Source: http://stackoverflow.com/questions/3682287/why-wont-my-windows-service-that-is-hosting-a-wcf-service-run-under-localservic
            // Example: netsh http add urlacl url=http://*:9999/ user=Everyone

            using (WebApp.Start<Startup>(listenUrl))
            {
                isRunning = true;

                // Keep the thread alive so that application doesn't exit
                var worker = new Worker();
                while (serviceStarted)
                {
                    worker.DoWork();
                    Thread.Sleep(100);
                }
            }
            isRunning = false;
        }
开发者ID:modulexcite,项目名称:2015-Slides-and-Demos,代码行数:23,代码来源:WebApiSelfhost.cs

示例4: DoWork

        /* Can't derive from sealed class.
        public class Slacker : Worker
        {
            override public void DoWork()
            {
                Console.WriteLine("DoNoWork");
            }
        }
         */
        public static void ClassExamples3Func()
        {
            Worker w= new Worker();

            w.DoWork();
        }
开发者ID:kennethnorman,项目名称:KenCSharpCodingSamples,代码行数:15,代码来源:ClassExamples3.cs

示例5: Main

        private static void Main(string[] args)
        {
            // Pipeline that dumps data to WorkPerformed1
            WorkPerformedHandler del1 = new WorkPerformedHandler(WorkPerformed1);

            WorkPerformedHandler del2 = new WorkPerformedHandler(WorkPerformed2);

            WorkPerformedHandler del3 = new WorkPerformedHandler(WorkPerformed2);

            del1(5, WorkType.Golf);
            del2(10, WorkType.GenerateReports);

            // Pass in deletage - del2 calls WorkPerformed2. It will invoke whatever was passed ie. WorkPerformed2
            DoWork(del2);

            // Adding handlers to Invocation list of Delegate1
            // Whenever del1 fires it will notify WorkPerformed2 and WorkPerformed3 as well
            del1 += del2;
            del1 += del3; // I could also do { del1 += del2 + del3 }

            // Events with Delegates
            // Attach handlers with delegates
            // Worker class 3 public events to wire up
            var worker = new Worker();

            // Without using Generic<T>
            worker.WorkPerformed += new WorkPerformedHandlerDelEvent(worker_WorkPerformed);

            // Wire event
            // specifying parameter signature match/pipeline
            worker.WorkPerfomedT += new EventHandler<WorkPerformedEventArgs>(worker_WorkPerformed);
            worker.WorkCompleted += worker_WorkCompleted; // Delegate Inference

            // Worker performs some task that exposes it's events. Whenever event is fired
            // subscribers (worker_WorkPerformed, worker_WorkCompleted) will be notified
            // Start work
            worker.DoWork(3, WorkType.GoToMeeting);

            // Testing class
            MyWorker w = new MyWorker();
            w.AttachListenerToMe += MyWorkerNotified;

            // Using Func with Events
            // Can't do this
            //w.AttachListenerToMe += Action<object, EventArgs> = (o, e) =>
            //    {
            //        Console.WriteLine();
            //    };

            string stringResult = w.DoWork();

            Console.Read();
        }
开发者ID:shanekm,项目名称:EventsDelegatesLambdas,代码行数:53,代码来源:Program.cs


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