forked from ddrilling/AsbCloudServer
Console1 nit
This commit is contained in:
parent
00fb84173b
commit
81fc9ae131
@ -21,119 +21,21 @@ namespace ConsoleApp1
|
||||
|
||||
class Program
|
||||
{
|
||||
static object lockObject = new();
|
||||
static int inc = 0;
|
||||
static void RefreshMonitor()
|
||||
{
|
||||
if (Monitor.TryEnter(lockObject))
|
||||
{
|
||||
Task.Delay(2_000);
|
||||
Interlocked.Increment(ref inc);
|
||||
}
|
||||
else
|
||||
Monitor.Wait(lockObject);
|
||||
|
||||
}
|
||||
|
||||
//static Mutex mutex = new Mutex();
|
||||
//static void RefreshMutex()
|
||||
//{
|
||||
// if(Mutex.TryOpenExisting()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// Interlocked.Increment(ref inc);
|
||||
//}
|
||||
|
||||
static bool isUnLocked = true;
|
||||
static void RefreshBool() {
|
||||
if(isUnLocked)
|
||||
{
|
||||
isUnLocked = false;
|
||||
Console.WriteLine(".");
|
||||
Task.Delay(50).Wait();
|
||||
inc++;
|
||||
isUnLocked = true;
|
||||
}
|
||||
while(!isUnLocked)
|
||||
Task.Delay(10).Wait();
|
||||
}
|
||||
|
||||
static readonly SemaphoreSlim semaphore = new(1);
|
||||
static void Refresh()
|
||||
{
|
||||
var wasFree = semaphore.CurrentCount > 0;
|
||||
semaphore.Wait();
|
||||
if (wasFree)
|
||||
{
|
||||
Console.WriteLine(".");
|
||||
Task.Delay(500).Wait();
|
||||
inc++;
|
||||
}
|
||||
semaphore.Release();
|
||||
}
|
||||
|
||||
static async Task RefreshAsync()
|
||||
{
|
||||
var wasFree = semaphore.CurrentCount == 1;
|
||||
await semaphore.WaitAsync();
|
||||
if (wasFree)
|
||||
{
|
||||
Console.WriteLine(".");
|
||||
await Task.Delay(500);
|
||||
inc++;
|
||||
}else
|
||||
Console.Write(",");
|
||||
semaphore.Release();
|
||||
}
|
||||
|
||||
static void Main(/*string[] args*/)
|
||||
{
|
||||
|
||||
Console.WriteLine(DateTime.Now.ToString("mm:ss.fff"));
|
||||
//semaphore.Release();
|
||||
Refresh();
|
||||
for (int i= 0; i < 4; i++)
|
||||
{
|
||||
var ts = new List<Task>(100);
|
||||
for (int j = 0; j < 20; j++)
|
||||
{
|
||||
ts.Add(
|
||||
Task.Run( RefreshAsync));
|
||||
}
|
||||
Task.WaitAll(ts.ToArray());
|
||||
Console.WriteLine("*");
|
||||
}
|
||||
|
||||
Console.WriteLine("_");
|
||||
Console.ReadKey();
|
||||
Console.WriteLine(inc);
|
||||
return;
|
||||
|
||||
|
||||
var options = new DbContextOptionsBuilder<AsbCloudDbContext>()
|
||||
.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=q;Persist Security Info=True")
|
||||
.Options;
|
||||
using var db = new AsbCloudDbContext(options);
|
||||
|
||||
var cacheDb = new CacheDb();
|
||||
var telemetryService = new TelemetryService(db, cacheDb);
|
||||
var analyticsService = new TelemetryAnalyticsService(db,
|
||||
telemetryService, cacheDb);
|
||||
var sw = new System.Diagnostics.Stopwatch();
|
||||
sw.Start();
|
||||
analyticsService.AnalyzeAndSaveTelemetriesAsync().Wait();
|
||||
sw.Stop();
|
||||
Console.WriteLine(sw.ElapsedMilliseconds);
|
||||
return;
|
||||
var ts = new TelemetryService(db, new CacheDb());
|
||||
var groups = ts.GetRedundentRemoteUids();
|
||||
foreach(var g in groups)
|
||||
ts.Merge(g.Ids);
|
||||
var wellService = new WellService(db, new TelemetryTracker(), cacheDb);
|
||||
|
||||
Console.WriteLine("Done. Press any key to quit.");
|
||||
Console.ReadKey();
|
||||
var wellOptsStat = new WellOperationsStatService(db, cacheDb, wellService);
|
||||
|
||||
var tvd = wellOptsStat.GetTvdAsync(1, default).Result;
|
||||
|
||||
Console.WriteLine("_");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user