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