繁体   English   中英

在Process.Start()之后看不到Process的UI

[英]UI of Process is not visible after Process.Start()

我做了一个WCF服务,它包含一个方法字符串SaveVideoInformation()

此方法的目的是运行一个未运行的进程。 以下是该方法的代码。

 public string SaveVideoInformation(string ID, string videoName)
    {
        string Result = null;
        try
        {
            Result = Insert(ID, videoName);
            Process[] pname = Process.GetProcessesByName("AutoRunVideoWaterMarkingTook");
            if (pname.Length == 0)
            {
                Result += " | Trying to run Process";
                try
                {
                    Process process = Process.Start(@"~\Debug\AutoRunVideoWaterMarkingTook.exe");
                    Result += " | Process Ran Successfully";
                }
                catch (Exception ex)
                {
                    Result += " | Exception While Running the process";
                    throw new Exception("Unable to start Process);
                }
            }
            else
            {
                Result += "|Process Already Running";
            }
        }
        catch (Exception ex)
        {
            Result = "Not Done," + ex.Message;
        }
        return Result;
    }

我面临的问题是当我从Windows窗体工具应用程序调用此方法时,它成功运行并且可以看到UI。

但是,当我从Windows Service调用此方法时,进程启动,但其UI不可见。

这很可能是因为Windows服务未处于用户交互模式。

您必须按照本博客中所述,从“服务”面板启用此功能:在服务属性“ Log On页面中,选中“ Allow service to interact with desktop

另请阅读Microsoft关于用户交互服务的建议

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM