Exemple #1
0
        private static void ProcessCommandLine()
        {
            var arguments = Environment.GetCommandLineArgs();

            if (arguments.Length == 1)
            {
                return;
            }

            try {
                var info = new FileInfo(arguments[1]);
                if (!info.Exists)
                {
                    return;
                }

                // Can't access the main window here directly since it is not yet created.
                DeferredActions.Push(() => {
                    Current.MainWindow.Loaded += async(sender, e) => {
                        Current.MainWindow.WindowState = WindowState.Minimized;
                        // Cannot await anonymous method.
                        await Context.InspectMessageAsync(info);
                    };
                });
            } catch (Exception ex) {
                Logger.Error(ex);
            }
        }
 private static void InvokeDeferredActions()
 {
     while (DeferredActions.HasActions)
     {
         var action = DeferredActions.Pop();
         try {
             action();
         }
         catch (Exception ex) {
             Logger.Error(ex);
         }
     }
 }
        public override unsafe void Flush()
        {
            IntPtr commandListHandleMem = RenderCommandTempMemPool.GetLocalPool().Reserve((uint)IntPtr.Size);

            QueueCommand(new RenderCommand(RenderCommandInstruction.FinishCommandList, (IntPtr)(&commandListHandleMem)));

            uint offset = 0U;
            bool success;

            for (int i = 0; i < DeferredActions.Count; i++)
            {
                KeyValuePair <uint, Action> curAction = DeferredActions[i];
                char *failReason = stackalloc char[InteropUtils.MAX_INTEROP_FAIL_REASON_STRING_LENGTH + 1];
                success = NativeMethods.RenderPassManager_FlushInstructions(
                    (IntPtr)failReason,
                    RenderingModule.DeviceContext,
                    RenderCommandList.AlignedPointer + (int)offset * sizeof(RenderCommand),
                    curAction.Key - offset
                    );
                if (!success)
                {
                    throw new NativeOperationFailedException(Marshal.PtrToStringUni((IntPtr)failReason));
                }
                offset = curAction.Key;
                curAction.Value();
            }

            char *failReason2 = stackalloc char[InteropUtils.MAX_INTEROP_FAIL_REASON_STRING_LENGTH + 1];

            success = NativeMethods.RenderPassManager_FlushInstructions(
                (IntPtr)failReason2,
                RenderingModule.DeviceContext,
                RenderCommandList.AlignedPointer + (int)offset * sizeof(RenderCommand),
                CurListIndex - offset
                );
            if (!success)
            {
                throw new NativeOperationFailedException(Marshal.PtrToStringUni((IntPtr)failReason2));
            }

            lastCommandListHandle = commandListHandleMem;

            LosgapSystem.InvokeOnMaster(invokeOnMasterAction);

            CurListIndex = 0U;
            DeferredActions.Clear();

            RenderCommandTempMemPool.GetLocalPool().FreeAll();
        }