Revision 8d2b4fa3
b/trunk/Pithos.Client.WPF/App.xaml.cs | ||
---|---|---|
63 | 63 |
public partial class App : Application |
64 | 64 |
{ |
65 | 65 |
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType ); |
66 |
|
|
67 |
|
|
66 |
|
|
68 | 67 |
|
69 | 68 |
public App() |
70 | 69 |
{ |
71 | 70 |
|
71 |
//var instanceMutex=new Mutex() |
|
72 |
|
|
72 | 73 |
InitializeLogging(); |
73 | 74 |
|
74 | 75 |
|
... | ... | |
84 | 85 |
Settings.Default.UseDefaultProxy = true; |
85 | 86 |
} |
86 | 87 |
|
88 |
|
|
87 | 89 |
InitializeComponent(); |
88 |
} |
|
90 |
} |
|
91 |
|
|
89 | 92 |
|
90 | 93 |
/* |
91 | 94 |
private void OnUpdateDetected(object sender, UpdateDetectedEventArgs e) |
... | ... | |
134 | 137 |
} |
135 | 138 |
} |
136 | 139 |
|
140 |
private Mutex _singleInstanceMutex; |
|
141 |
|
|
137 | 142 |
protected override void OnStartup(StartupEventArgs e) |
138 | 143 |
{ |
139 | 144 |
if (!Settings.Default.StartOnSystemStartup && e.Args.Contains("startup")) |
... | ... | |
142 | 147 |
return; |
143 | 148 |
} |
144 | 149 |
|
150 |
bool firstInstance; |
|
151 |
_singleInstanceMutex = new Mutex(false, "PITHOSMUTEX", out firstInstance); |
|
152 |
if (!firstInstance) |
|
153 |
{ |
|
154 |
_singleInstanceMutex.Dispose(); |
|
155 |
_singleInstanceMutex = null; |
|
156 |
Shutdown(); |
|
157 |
return; |
|
158 |
} |
|
159 |
|
|
145 | 160 |
//Delay during startup |
146 | 161 |
if (e.Args.Contains("startup")) |
147 | 162 |
{ |
... | ... | |
155 | 170 |
base.OnStartup(e); |
156 | 171 |
} |
157 | 172 |
|
173 |
protected override void OnExit(ExitEventArgs e) |
|
174 |
{ |
|
175 |
try |
|
176 |
{ |
|
177 |
if (_singleInstanceMutex!=null) |
|
178 |
_singleInstanceMutex.Dispose(); |
|
179 |
_singleInstanceMutex = null; |
|
180 |
} |
|
181 |
catch { } |
|
182 |
base.OnExit(e); |
|
183 |
} |
|
184 |
|
|
158 | 185 |
private void OnUnobservedException(object sender, UnobservedTaskExceptionEventArgs e) |
159 | 186 |
{ |
160 | 187 |
var messages=new List<UserMessage>(); |
b/trunk/Pithos.Client.WPF/Pithos.Client.WPF.csproj | ||
---|---|---|
237 | 237 |
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> |
238 | 238 |
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> |
239 | 239 |
</PropertyGroup> |
240 |
<PropertyGroup> |
|
241 |
<StartupObject> |
|
242 |
</StartupObject> |
|
243 |
</PropertyGroup> |
|
240 | 244 |
<ItemGroup> |
241 | 245 |
<Reference Include="AsyncCtpLibrary"> |
242 | 246 |
<HintPath>..\Libraries\AsyncCtpLibrary.dll</HintPath> |
Also available in: Unified diff