所以我有以下代码-
using System;
using System.Globalization;
using Hangfire;
using Microsoft.Owin.Hosting;
namespace HangfireTests
{
public class HangfireTests
{
public HangfireTests()
{
}
public void Start()
{
WebApp.Start<Startup>("http://localhost:8888");
Console.WriteLine("Server started... press any key to shut down");
RecurringJob.AddOrUpdate("systeminfo",
() => GetTime(), Cron.Minutely);
RecurringJob.AddOrUpdate("checktask",
() => GetTime(), Cron.Minutely);
}
public static string GetTime()
{
var now = DateTime.Now.ToString(CultureInfo.InvariantCulture);
Console.WriteLine(now);
return now;
}
public void Stop()
{
}
}
}
它运行,但是第一个线程比循环计数(1000)运行更多的迭代,第二个线程比其循环计数(1000)更少的迭代。有人可以指出这段代码有什么问题吗?非常感谢您的帮助。