microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dev

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Extensions/Microsoft.Teams.Extensions.Hosting/Microsoft.Teams.Apps.Extensions/TeamsService.cs

57lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Extensions.Hosting;
5using Microsoft.Extensions.Logging;
6
7namespace Microsoft.Teams.Apps.Extensions;
8
9public class TeamsService : IHostedLifecycleService
10{
11 protected App _app;
12 protected ILogger<App> _logger;
13
14 public TeamsService(App app, ILogger<App> logger)
15 {
16 _app = app;
17 _logger = logger;
18 }
19
20 public Task StartingAsync(CancellationToken cancellationToken)
21 {
22 _logger.LogDebug("Starting");
23 return Task.CompletedTask;
24 }
25
26 public Task StartAsync(CancellationToken cancellationToken)
27 {
28 _logger.LogDebug("Start");
29 return Task.CompletedTask;
30 }
31
32 public async Task StartedAsync(CancellationToken cancellationToken)
33 {
34 await _app.Start(cancellationToken);
35 _logger.LogDebug("Started");
36 }
37
38 public Task StoppingAsync(CancellationToken cancellationToken)
39 {
40 _logger.LogDebug("Stopping");
41 var src = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
42 src.Cancel();
43 return Task.CompletedTask;
44 }
45
46 public Task StopAsync(CancellationToken cancellationToken)
47 {
48 _logger.LogDebug("Stop");
49 return Task.CompletedTask;
50 }
51
52 public Task StoppedAsync(CancellationToken cancellationToken)
53 {
54 _logger.LogDebug("Stopped");
55 return Task.CompletedTask;
56 }
57}