本文整理汇总了C#中System.Clock.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Clock.Start方法的具体用法?C# Clock.Start怎么用?C# Clock.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Clock
的用法示例。
在下文中一共展示了Clock.Start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run_All
/// <summary>
/// Runs all tests 27-127
/// </summary>
//[TestCase]
public void Run_All()
{
for (int i = 27; i <= 127; i++)
{
var clock = new Clock(i);
var result = clock.Start();
Assert.IsTrue(result.StartsWith(i.ToString()));
}
}
示例2: Start
/// <summary>
/// 启动计时器
/// </summary>
/// <param name="interval">计时器间隔</param>
/// <param name="count">执行次数</param>
/// <param name="key">计时器标志</param>
/// <param name="func">回调函数</param>
public static bool Start(float interval, int count, string key, TimerCallBackHandle func)
{
Clock ck = new Clock();
if (!mapClock.ContainsKey(key))
{
mapClock.Add(key, ck);
ck.Start(interval, count, func);
}
else
{
return false;
}
return true;
}
示例3: Run
public async void Run(IBackgroundTaskInstance taskInstance)
{
_taskInstance = taskInstance;
_deferral = _taskInstance.GetDeferral();
_taskInstance.Canceled += TaskInstance_Canceled;
var gpio = GpioController.GetDefault();
// turn off red en green led
//var red = gpio.OpenPin(35);
//red.Write(GpioPinValue.Low);
//red.SetDriveMode(GpioPinDriveMode.Output);
//var green = gpio.OpenPin(47);
//green.Write(GpioPinValue.Low);
//green.SetDriveMode(GpioPinDriveMode.Output);
// power cycle +3v3 to reset all I2C devices
//_shdn = gpio.OpenPin(5);
//_shdn.Write(GpioPinValue.High);
//_shdn.SetDriveMode(GpioPinDriveMode.Output);
//_shdn.Write(GpioPinValue.Low);
//// wait to discharge all capacitors
//Task.Delay(3000).GetAwaiter().GetResult();
//_shdn.Write(GpioPinValue.High);
_heater = gpio.OpenPin(16);
_heater.Write(GpioPinValue.Low);
_heater.SetDriveMode(GpioPinDriveMode.Output);
_clock = new Clock();
_clock.Start();
await Init();
await _clock.Init();
_bme280 = new BME280();
await _bme280.Init();
//_timer2 = ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick2, TimeSpan.FromMilliseconds(4));
_timer3 = ThreadPoolTimer.CreatePeriodicTimer(Timer_Tick3, TimeSpan.FromMinutes(1));
}
示例4: Search
public override SearchResult Search(Board board, int color,int depth)
{
SearchResult searchResult = new SearchResult();
//board.CurrentColor = color;
//PrepareToSolve(board);
int alpha = -MaxScore - 1;
int beta = MaxScore + 1;
int opp = color.Opp();
Clock clock = new Clock();
clock.Start();
//Roulette roulette = new Roulette();
//board.RefreshHash();
int score = -MaxScore;
int eval;
//是否调用零窗口的标志
bool foundPv = false;
var moves = rule.FindFlips(board, color).ToList();
if (moves.Count == 0) {
return new SearchResult() { Move = -1 };
}
//if (moves.Count == 1) {
// return new SearchResult() { Move = moves.First().Pos };
//}
for (int i = 0; i < moves.Count; i++) {
var pos = moves[i].Pos;
//下棋
//---------------------------
int flipCount = board.MakeMove(pos, color);
searchResult.Nodes++;
//检测
if (foundPv) {
//调用零窗口
eval = -FastestFirstSolve(board, -alpha - 1, -alpha, depth - 1, searchResult, opp, color);
if ((eval > alpha) && (eval < beta)) {
eval = -FastestFirstSolve(board, -beta, -eval, depth - 1, searchResult, opp, color);
//eval = -FastestFirstMidSolve( -beta, -alpha, oppcolor, depth - 1);
}
}
else {
eval = -FastestFirstSolve(board, -beta, -alpha, depth - 1, searchResult, opp, color);
}
//em.ReLink();
//---------------------------
//Eval.StepsPop(color);
//恢复到上一步
board.Reback(pos, flipCount, opp);
searchResult.Message += string.Format("({0}:{1})", pos, eval);
if (eval > score) {
score = eval;
//更新位置
searchResult.Move = pos;
searchResult.Score = score;
if (eval > alpha) {
if (eval >= beta) {
//剪枝
break;
}
alpha = eval;
foundPv = true;
}
}
}
clock.Stop();
searchResult.TimeSpan = clock.Elapsed;
return searchResult;
}
示例5: Run_ReturnsStringStartingWithTheNumberOfBallsGiven
public void Run_ReturnsStringStartingWithTheNumberOfBallsGiven()
{
var expected = 27;
var clock = new Clock(expected);
Assert.IsTrue(clock.Start().StartsWith(expected.ToString()));
}
示例6: Run_Returns378DaysWhenGiven45Balls
public void Run_Returns378DaysWhenGiven45Balls()
{
var clock = new Clock(45);
Assert.AreEqual("45 balls cycle after 378 days", clock.Start());
}
示例7: Run_Returns15DaysWhenGiven30Balls
public void Run_Returns15DaysWhenGiven30Balls()
{
var clock = new Clock(30);
Assert.AreEqual("30 balls cycle after 15 days", clock.Start());
}