private object WrapVoid(Func <object[], object> target, object[] args) { try { MaskExtensions.Show(); Task.Delay(delay); return(target(args)); } catch (Exception e) { MessageBox.Show("攔截方法出錯,原因:" + e.Message + ",請檢查被攔截的方法參數是否正確。", "系統提示", (MessageBoxButton)0, (MessageBoxImage)16); return(default);
private static async Task WrapTaskAsync(Func <object[], object> target, object[] args) { try { MaskExtensions.Show(); await Task.Delay(delay); await(Task) target(args); } catch (Exception e) { MessageBox.Show("攔截方法出錯,原因:" + e.Message + ",請檢查被攔截的方法參數是否正確。", "系統提示", (MessageBoxButton)0, (MessageBoxImage)16); } finally { ServiceLocator.Current.TryResolve <IEventAggregator>().GetEvent <ConstrolStateEvent>().Publish(new ControlState { IsEnabled = true }); MaskExtensions.Close(); } }