Fix Wox restart

1. refactoring restart
2. delte some windows forms methods
3. using string inteperlation and delete hard coeded new line char

should fix #322
This commit is contained in:
bao-qian
2015-11-26 02:04:44 +00:00
parent f0765ba743
commit 6023f415a4
9 changed files with 71 additions and 58 deletions

View File

@@ -212,6 +212,8 @@ namespace Wox.Helper
where TApplication: Application , ISingleInstanceApp
{
public const string Restart = "Restart";
#region Private Fields
/// <summary>
@@ -273,6 +275,8 @@ namespace Wox.Helper
public static bool InitializeAsFirstInstance( string uniqueName )
{
commandLineArgs = GetCommandLineArgs(uniqueName);
//remove execute path itself
commandLineArgs.RemoveAt(0);
// Build unique application Id and the IPC channel name.
string applicationIdentifier = uniqueName + Environment.UserName;
@@ -285,13 +289,20 @@ namespace Wox.Helper
if (firstInstance)
{
CreateRemoteService(channelName);
return true;
}
else if (commandLineArgs.Count > 0 && commandLineArgs[0] == Restart)
{
SignalFirstInstance(channelName, commandLineArgs);
singleInstanceMutex = new Mutex(true, applicationIdentifier);
CreateRemoteService(channelName);
return true;
}
else
{
SignalFirstInstance(channelName, commandLineArgs);
return false;
}
return firstInstance;
}
/// <summary>
@@ -442,8 +453,7 @@ namespace Wox.Helper
{
return;
}
//remove execute path itself
args.RemoveAt(0);
((TApplication)Application.Current).OnActivate(args);
}