Add new interfaces

This commit is contained in:
Jack251970 2025-03-29 22:03:30 +08:00
parent 9005c93c2f
commit e0721aae14
2 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Asynchronous Query Model for Flow Launcher When Query Text is Empty
/// </summary>
public interface IAsyncEmptyQuery
{
/// <summary>
/// Asynchronous Querying When Query Text is Empty
/// </summary>
/// <para>
/// If the Querying method requires high IO transmission
/// or performing CPU intense jobs (performing better with cancellation), please use this IAsyncEmptyQuery interface
/// </para>
/// <param name="token">Cancel when querying job is obsolete</param>
/// <returns></returns>
Task<List<Result>> EmptyQueryAsync(CancellationToken token);
}
}

View file

@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Synchronous Query Model for Flow Launcher When Query Text is Empty
/// <para>
/// If the Querying method requires high IO transmission
/// or performaing CPU intense jobs (performing better with cancellation), please try the IAsyncEmptyQuery interface
/// </para>
/// </summary>
public interface IEmptyQuery : IAsyncEmptyQuery
{
/// <summary>
/// Querying When Query Text is Empty
/// <para>
/// This method will be called within a Task.Run,
/// so please avoid synchrously wait for long.
/// </para>
/// </summary>
/// <returns></returns>
List<Result> EmptyQuery();
Task<List<Result>> IAsyncEmptyQuery.EmptyQueryAsync(CancellationToken token) => Task.Run(EmptyQuery);
}
}