1234567891011121314151617181920212223242526272829303132333435363738 |
- namespace System
- {
- public static class ActionUtils
- {
- /// <summary>
- /// ActionµÄ°²È«»Øµ÷
- /// </summary>
- /// <param name="action"></param>
- public static void SafeInvoke(this Action action)
- {
- try
- {
- action?.Invoke();
- }
- catch (Exception ex)
- {
- XGame.Log.Exception(ex);
- }
- }
- /// <summary>
- /// ActionµÄ°²È«»Øµ÷
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="action"></param>
- /// <param name="obj"></param>
- public static void SafeInvoke<T>(this Action<T> action, T obj)
- {
- try
- {
- action?.Invoke(obj);
- }
- catch (Exception ex)
- {
- XGame.Log.Exception(ex);
- }
- }
- }
- }
|