| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
446 バイト追加 、 2021年7月4日 (日) 05:41
編集の要約なし
| [[.NET Core]] | [[ASP.NET Core]] | [[C Sharp]] |
==.NET Core Console/Worker==
===汎用HOST===
*https://docs.microsoft.com/ja-jp/dotnet/core/extensions/generic-host
</pre>
*サービス*ワーカー
<pre>
namespace docwebusing System;using System.Collections.Generic;using System.Linq;using System.Net.Http;using System.Text;using System.Threading;using System.Threading.Tasks;using docweb_bat2.Services;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.Hosting;using Microsoft.Extensions.Logging;using MongoDB.Bson;using MongoDB.Driver;using Newtonsoft.Json; namespace docweb_bat2
{
public class DocumentWebService Worker : BackgroundService
{
// コンストラクタインジェクションprivate readonly ILogger<Worker> _logger;  private IConfiguration _config; private DocumentWebService _service;  static readonly HttpClient client = new HttpClient();  public DocumentWebServiceWorker(IConfiguration configurationILogger<Worker> logger, IDocumentWebDatabaseSettings settingsIConfiguration config, DocumentWebService service)
{
_logger = logger;
_config = config;
_service = service;
}
}}</pre>*JOB<pre>namespace docweb_bat.Jobs{ public class GetCollection { DocumentWebService _service; public GetCollection(DocumentWebService service) { this._service = service; } public void Runprotected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
}
}
}
}
</pre>

案内メニュー