12 changed files with 148 additions and 65 deletions
@ -1,7 +0,0 @@ |
|||
<Directives> |
|||
<Application> |
|||
<Assembly Name="ControlCatalog" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Default" Dynamic="Required All"></Assembly> |
|||
<Assembly Name="Avalonia.Themes.Fluent" Dynamic="Required All"></Assembly> |
|||
</Application> |
|||
</Directives> |
|||
@ -1,3 +1,4 @@ |
|||
Compat issues with assembly Avalonia.Base: |
|||
MembersMustExist : Member 'public System.Int32 System.Int32 Avalonia.Threading.DispatcherPriority.value__' does not exist in the implementation but it does exist in the contract. |
|||
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Threading.IDispatcher.Post<T>(System.Action<T>, T, Avalonia.Threading.DispatcherPriority)' is present in the implementation but not in the contract. |
|||
Total Issues: 1 |
|||
Total Issues: 2 |
|||
|
|||
@ -1,74 +1,121 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Threading |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the priorities with which jobs can be invoked on a <see cref="Dispatcher"/>.
|
|||
/// </summary>
|
|||
// TODO: These are copied from WPF - many won't apply to Avalonia.
|
|||
public enum DispatcherPriority |
|||
public readonly struct DispatcherPriority : IEquatable<DispatcherPriority>, IComparable<DispatcherPriority> |
|||
{ |
|||
/// <summary>
|
|||
/// The integer value of the priority
|
|||
/// </summary>
|
|||
public int Value { get; } |
|||
|
|||
private DispatcherPriority(int value) |
|||
{ |
|||
Value = value; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Minimum possible priority
|
|||
/// </summary>
|
|||
MinValue = 1, |
|||
|
|||
public static readonly DispatcherPriority MinValue = new(0); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed when the system is idle.
|
|||
/// </summary>
|
|||
SystemIdle = 1, |
|||
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority SystemIdle = MinValue; |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed when the application is idle.
|
|||
/// </summary>
|
|||
ApplicationIdle = 2, |
|||
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority ApplicationIdle = MinValue; |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed after background operations have completed.
|
|||
/// </summary>
|
|||
ContextIdle = 3, |
|||
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority ContextIdle = MinValue; |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed after other non-idle operations have completed.
|
|||
/// The job will be processed with normal priority.
|
|||
/// </summary>
|
|||
Background = 4, |
|||
public static readonly DispatcherPriority Normal = MinValue; |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed with the same priority as input.
|
|||
/// The job will be processed after other non-idle operations have completed.
|
|||
/// </summary>
|
|||
Input = 5, |
|||
public static readonly DispatcherPriority Background = new(1); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed after layout and render but before input.
|
|||
/// The job will be processed with the same priority as input.
|
|||
/// </summary>
|
|||
Loaded = 6, |
|||
public static readonly DispatcherPriority Input = new(2); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed with the same priority as render.
|
|||
/// The job will be processed after layout and render but before input.
|
|||
/// </summary>
|
|||
Render = 7, |
|||
public static readonly DispatcherPriority Loaded = new(3); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed with the same priority as render.
|
|||
/// </summary>
|
|||
Layout = 8, |
|||
|
|||
public static readonly DispatcherPriority Render = new(5); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed with the same priority as data binding.
|
|||
/// The job will be processed with the same priority as render.
|
|||
/// </summary>
|
|||
DataBind = 9, |
|||
public static readonly DispatcherPriority Layout = new(6); |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed with normal priority.
|
|||
/// The job will be processed with the same priority as data binding.
|
|||
/// </summary>
|
|||
Normal = 10, |
|||
[Obsolete("WPF compatibility")] public static readonly DispatcherPriority DataBind = MinValue; |
|||
|
|||
/// <summary>
|
|||
/// The job will be processed before other asynchronous operations.
|
|||
/// </summary>
|
|||
Send = 11, |
|||
|
|||
public static readonly DispatcherPriority Send = new(7); |
|||
|
|||
/// <summary>
|
|||
/// Maximum possible priority
|
|||
/// </summary>
|
|||
MaxValue = 11 |
|||
public static readonly DispatcherPriority MaxValue = Send; |
|||
|
|||
// Note: unlike ctor this one is validating
|
|||
public static DispatcherPriority FromValue(int value) |
|||
{ |
|||
if (value < MinValue.Value || value > MaxValue.Value) |
|||
throw new ArgumentOutOfRangeException(nameof(value)); |
|||
return new DispatcherPriority(value); |
|||
} |
|||
|
|||
public static implicit operator int(DispatcherPriority priority) => priority.Value; |
|||
|
|||
public static implicit operator DispatcherPriority(int value) => FromValue(value); |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(DispatcherPriority other) => Value == other.Value; |
|||
|
|||
/// <inheritdoc />
|
|||
public override bool Equals(object? obj) => obj is DispatcherPriority other && Equals(other); |
|||
|
|||
/// <inheritdoc />
|
|||
public override int GetHashCode() => Value.GetHashCode(); |
|||
|
|||
public static bool operator ==(DispatcherPriority left, DispatcherPriority right) => left.Value == right.Value; |
|||
|
|||
public static bool operator !=(DispatcherPriority left, DispatcherPriority right) => left.Value != right.Value; |
|||
|
|||
public static bool operator <(DispatcherPriority left, DispatcherPriority right) => left.Value < right.Value; |
|||
|
|||
public static bool operator >(DispatcherPriority left, DispatcherPriority right) => left.Value > right.Value; |
|||
|
|||
public static bool operator <=(DispatcherPriority left, DispatcherPriority right) => left.Value <= right.Value; |
|||
|
|||
public static bool operator >=(DispatcherPriority left, DispatcherPriority right) => left.Value >= right.Value; |
|||
|
|||
/// <inheritdoc />
|
|||
public int CompareTo(DispatcherPriority other) => Value.CompareTo(other.Value); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue