First in 202205060145

This commit is contained in:
Youmu_Liu_NLI
2022-05-06 01:45:42 +08:00
commit bd948f60d6
243 changed files with 583275 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
namespace Threding_Demo2
{
class Program
{
static void Main(string[] args)
{
long frequency = Stopwatch.Frequency;
Console.WriteLine("Timer frequency in ticks per second = {0}",frequency);
long nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
Console.WriteLine("Timer is accurate within {0} nanoseconds",nanosecPerTick);
}
}
class demo
{
public Stopwatch Stopwatcher { get; set; }
public demo()
{
this.Stopwatcher = new Stopwatch();
}
public void PreSpin(Stopwatch a, double duration)
{
var current = a.ElapsedTicks;
while ((a.ElapsedTicks-current)<duration )
{
Thread.SpinWait(10);
}
}
public void Spin(Stopwatch a, double duration)
{
this.PreSpin(a,duration);
}
}
}