//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// AFXUI auxiliary module for Blazor-application (WASM) | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;

using CommonHelpers.WASM;

namespace AFXUI {

//**************************************************************************************************
static partial class UCircuit {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="ArgumentNullException" />
public static Task<int> DoStaticBlocking_A( [HRequired] MethodBase? method, Func<Task> bodyA ) =>
   DoStaticBlocking_A( method, new UCircuitExtraParams(), bodyA );
/// <exception cref="ArgumentNullException" />
public static Task<int> DoStaticBlocking_A( [HRequired] MethodBase? method,
                                            Func<bool>? preliminary, Func<Task> bodyA ) =>
   DoStaticBlocking_A( method, new UCircuitExtraParams(), preliminary, bodyA );

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static Task<int> DoStaticBlocking_A( bool useWaitingCursor,
                                            [HRequired] MethodBase? method, Func<Task> bodyA ) =>
   DoStaticBlocking_A( useWaitingCursor, method, new UCircuitExtraParams(), bodyA );
/// <exception cref="ArgumentNullException" />
public static Task<int> DoStaticBlocking_A( bool useWaitingCursor, [HRequired] MethodBase? method,
                                            Func<bool>? preliminary, Func<Task> bodyA ) =>
   DoStaticBlocking_A( useWaitingCursor, method, new UCircuitExtraParams(), preliminary, bodyA );

//==================================================================================================

/// <exception cref="ArgumentNullException" />
public static async Task<int> DoStaticBlocking_A( [HRequired] MethodBase? method,
                                                  UCircuitExtraParams extraParams,
                                                  Func<Task> bodyA )
=>
   await UBreakdown.ReturnVal_A<int>(async()=>{
      if ( !CheckBlocking( method ) )
         return 0;
      using (new UInputBlocking())
         return await DoStatic_A( 1, method, extraParams, bodyA );
   }) ?? Int32.MinValue+1;

/// <exception cref="ArgumentNullException" />
public static async Task<int> DoStaticBlocking_A( [HRequired] MethodBase? method,
                                                  UCircuitExtraParams extraParams, 
                                                  Func<bool>? preliminary, Func<Task> bodyA )
=>
   await UBreakdown.ReturnVal_A<int>(async()=>{
      if ( !CheckBlocking( method ) )
         return 0;
      using (new UInputBlocking())
         return await DoStatic_A( 1, method, extraParams, preliminary, bodyA );
   }) ?? Int32.MinValue+1;

//--------------------------------------------------------------------------------------------------

/// <exception cref="ArgumentNullException" />
public static async Task<int> DoStaticBlocking_A( bool useWaitingCursor,
                                                  [HRequired] MethodBase? method,
                                                  UCircuitExtraParams extraParams,
                                                  Func<Task> bodyA )
=>
   await UBreakdown.ReturnVal_A<int>(async()=>{
      if ( !CheckBlocking( method ) )
         return 0;
      using (new UInputBlocking(useWaitingCursor))
         return await DoStatic_A( 1, method, extraParams, bodyA );
   }) ?? Int32.MinValue+1;

/// <exception cref="ArgumentNullException" />
public static async Task<int> DoStaticBlocking_A( bool useWaitingCursor,
                                                  [HRequired] MethodBase? method,
                                                  UCircuitExtraParams extraParams, 
                                                  Func<bool>? preliminary, Func<Task> bodyA )
=>
   await UBreakdown.ReturnVal_A<int>(async()=>{
      if ( !CheckBlocking( method ) )
         return 0;
      using (new UInputBlocking(useWaitingCursor))
         return await DoStatic_A( 1, method, extraParams, preliminary, bodyA );
   }) ?? Int32.MinValue+1;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // UCircuit
//**************************************************************************************************

} // AFXUI
