Lock Form UI While Doing Some Work Behind

PHOTO EMBED

Mon Aug 22 2022 12:15:54 GMT+0000 (UTC)

Saved by @HristoT #c#

public static async Task LockExtAsync(this XtraForm xtraForm, Func<Task> onLock)
{


   IOverlaySplashScreenHandle zzz = null;
   try
   {
       xtraForm.Enabled = false;
       zzz = SplashScreenManager.ShowOverlayForm(xtraForm);
       await onLock();
   }
   finally
   {
       SplashScreenManager.CloseOverlayForm(zzz);
       xtraForm.Enabled = true;
   }

}

// USAGE
await form.LockExtAsync(async () =>
{
	// Login here
});
content_copyCOPY