【发布时间】:2017-06-12 12:56:40
【问题描述】:
我正在为 CAM/CAD 软件编写插件/界面,并使用此代码打开“SaveWindow”。
public void Run(string theMode)
{
try
{
if (theMode == "SaveWindow")
{
string aPictureString = GetPictureString();
StartInterface(null, theMode, CreateAndSaveTheToolList(aPictureString));
}
else
{
string aPipeId = GetRandomString();
itsServerStream = new NamedPipeServerStream(aPipeId, PipeDirection.In, 1);
ThreadPool.QueueUserWorkItem(this.ListenToStream);
StartInterface(aPipeId, theMode, "");
StartNamedPipe(aPipeId);
itsRefreshThread = new Thread(this.RefreshTools);
itsRefreshThread.Start();
if (!InitLogger(Path.GetDirectoryName(this.GetType().Assembly.Location)))
{
MessageBox.Show(//Secured code);
return;
}
}
itsLogger.Info("Run execute was successful.");
}
catch (Exception aException)
{
//Secured code
}
LogManager.ResetConfiguration();
}
如果有一个接口打开,我再次点击插件按钮,它会打开另一个多个。如果第一个是打开的,我如何编码不打开第二个。
【问题讨论】:
-
最好是询问支持,因为您可能缺少某种“独家”插件选项。否则,您可以尝试 IPC 同步,例如named mutex.
标签: c# winforms button plugins