mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 17:06:12 +02:00
Add cancellation support to AsyncPlugin methods
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DesktopMagic.Api;
|
||||
@@ -15,11 +16,23 @@ namespace DesktopMagic.Api;
|
||||
/// intervals, and configuration changes as needed.</remarks>
|
||||
public abstract class AsyncPlugin : Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs once when the plugin gets activated. Override for async initialization.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Token signaled when the host requests cancellation.</param>
|
||||
public virtual Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs once when the plugin gets deactivated. Override for async cleanup.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Token signaled when the host requests cancellation.</param>
|
||||
public virtual Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Plugin.UpdateInterval"/> elapses.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract Task<Bitmap?> MainAsync();
|
||||
public abstract Task<Bitmap?> MainAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// This method should not be called directly! Override and use <see cref="MainAsync"/> for asynchronous plugin operations.
|
||||
|
||||
Reference in New Issue
Block a user