예제 #1
0
    // データベース更新メイン
    async Task <int> WriteCoreAsync(CancellationToken cancel)
    {
        int num = 0;

        await using var db = await OpenDatabaseForWriteAsync(cancel);

        await db.EnsureOpenAsync(cancel);

        // キューが空になるまで 実施 いたします
        while (cancel.IsCancellationRequested == false)
        {
            ThinDatabaseUpdateJob?queue = null;

            if (LazyUpdateJobQueue.TryDequeue(out queue) == false)
            {
                break;
            }

            Controller.Throughput_DatabaseWrite.Add(1);

            RetryHelper <int> r = new RetryHelper <int>(100, 10);

            await r.RunAsync(async c =>
            {
                await queue.ProcAsync(db, c);

                return(0);
            }, cancel : cancel);

            num++;
        }

        return(num);
    }