CM3D2.MaidFiddler.Plugin.Utils.Debugger.Assert C# (CSharp) Method

Assert() public static method

public static Assert ( System.Action action, string errMsg ) : void
action System.Action
errMsg string
return void
        public static void Assert(Action action, string errMsg)
        {
            try
            {
                action();
            }
            catch (Exception e)
            {
                ErrorOccured?.Invoke(e, errMsg);
            }
        }

Usage Example

        public void UpdateSelectedMaidValues()
        {
            if (InvokeRequired)
            {
                InvokeAsync((Action)UpdateSelectedMaidValues);
                return;
            }
            MaidChangeType cType = 0;

            Debugger.Assert(
                () =>
            {
                int processingQueue = currentQueue;
                currentQueue        = 1 - currentQueue;
                if (valueUpdateQueue[processingQueue].Count <= 0)
                {
                    return;
                }
                Debugger.WriteLine(LogLevel.Info, $"Updating values (Queue {processingQueue})...");
                foreach (KeyValuePair <MaidChangeType, Action> type in valueUpdateQueue[processingQueue])
                {
                    cType = type.Key;
                    type.Value();
                }
                valueUpdateQueue[processingQueue].Clear();
            },
                $"Failed to update scheduled maid value. Type: {cType}");
        }
All Usage Examples Of CM3D2.MaidFiddler.Plugin.Utils.Debugger::Assert