diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-05-03 15:30:50 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-05-04 10:05:21 -0500 |
commit | 29f7e00586412163a20e298fbf84505f8a917425 (patch) | |
tree | 30257a3544f6982ded159443ebed0eb933f11a51 /src/api/burn/WixToolset.Mba.Core | |
parent | 41d2c12d60ee84cefc26ec99abb328701883c8f5 (diff) | |
download | wix-29f7e00586412163a20e298fbf84505f8a917425.tar.gz wix-29f7e00586412163a20e298fbf84505f8a917425.tar.bz2 wix-29f7e00586412163a20e298fbf84505f8a917425.zip |
Only block shutdown during Apply.
Diffstat (limited to 'src/api/burn/WixToolset.Mba.Core')
4 files changed, 0 insertions, 93 deletions
diff --git a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs index 6738a4a6..bb34a33e 100644 --- a/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/BootstrapperApplication.cs | |||
@@ -22,15 +22,12 @@ namespace WixToolset.Mba.Core | |||
22 | /// </summary> | 22 | /// </summary> |
23 | protected readonly IEngine engine; | 23 | protected readonly IEngine engine; |
24 | 24 | ||
25 | private bool applying; | ||
26 | |||
27 | /// <summary> | 25 | /// <summary> |
28 | /// Creates a new instance of the <see cref="BootstrapperApplication"/> class. | 26 | /// Creates a new instance of the <see cref="BootstrapperApplication"/> class. |
29 | /// </summary> | 27 | /// </summary> |
30 | protected BootstrapperApplication(IEngine engine) | 28 | protected BootstrapperApplication(IEngine engine) |
31 | { | 29 | { |
32 | this.engine = engine; | 30 | this.engine = engine; |
33 | this.applying = false; | ||
34 | this.asyncExecution = true; | 31 | this.asyncExecution = true; |
35 | } | 32 | } |
36 | 33 | ||
@@ -41,9 +38,6 @@ namespace WixToolset.Mba.Core | |||
41 | public event EventHandler<ShutdownEventArgs> Shutdown; | 38 | public event EventHandler<ShutdownEventArgs> Shutdown; |
42 | 39 | ||
43 | /// <inheritdoc/> | 40 | /// <inheritdoc/> |
44 | public event EventHandler<SystemShutdownEventArgs> SystemShutdown; | ||
45 | |||
46 | /// <inheritdoc/> | ||
47 | public event EventHandler<DetectBeginEventArgs> DetectBegin; | 41 | public event EventHandler<DetectBeginEventArgs> DetectBegin; |
48 | 42 | ||
49 | /// <inheritdoc/> | 43 | /// <inheritdoc/> |
@@ -332,25 +326,6 @@ namespace WixToolset.Mba.Core | |||
332 | } | 326 | } |
333 | 327 | ||
334 | /// <summary> | 328 | /// <summary> |
335 | /// Called by the engine, raises the <see cref="SystemShutdown"/> event. | ||
336 | /// </summary> | ||
337 | /// <param name="args">Additional arguments for this event.</param> | ||
338 | protected virtual void OnSystemShutdown(SystemShutdownEventArgs args) | ||
339 | { | ||
340 | EventHandler<SystemShutdownEventArgs> handler = this.SystemShutdown; | ||
341 | if (null != handler) | ||
342 | { | ||
343 | handler(this, args); | ||
344 | } | ||
345 | else if (null != args) | ||
346 | { | ||
347 | // Allow requests to shut down when critical or not applying. | ||
348 | bool critical = EndSessionReasons.Critical == (EndSessionReasons.Critical & args.Reasons); | ||
349 | args.Cancel = !critical && this.applying; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | /// <summary> | ||
354 | /// Called by the engine, raises the <see cref="DetectBegin"/> event. | 329 | /// Called by the engine, raises the <see cref="DetectBegin"/> event. |
355 | /// </summary> | 330 | /// </summary> |
356 | /// <param name="args">Additional arguments for this event.</param> | 331 | /// <param name="args">Additional arguments for this event.</param> |
@@ -1433,15 +1408,6 @@ namespace WixToolset.Mba.Core | |||
1433 | return args.HResult; | 1408 | return args.HResult; |
1434 | } | 1409 | } |
1435 | 1410 | ||
1436 | int IBootstrapperApplication.OnSystemShutdown(EndSessionReasons dwEndSession, ref bool fCancel) | ||
1437 | { | ||
1438 | SystemShutdownEventArgs args = new SystemShutdownEventArgs(dwEndSession, fCancel); | ||
1439 | this.OnSystemShutdown(args); | ||
1440 | |||
1441 | fCancel = args.Cancel; | ||
1442 | return args.HResult; | ||
1443 | } | ||
1444 | |||
1445 | int IBootstrapperApplication.OnDetectBegin(bool fCached, RegistrationType registrationType, int cPackages, ref bool fCancel) | 1411 | int IBootstrapperApplication.OnDetectBegin(bool fCached, RegistrationType registrationType, int cPackages, ref bool fCancel) |
1446 | { | 1412 | { |
1447 | DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, registrationType, cPackages, fCancel); | 1413 | DetectBeginEventArgs args = new DetectBeginEventArgs(fCached, registrationType, cPackages, fCancel); |
@@ -1693,8 +1659,6 @@ namespace WixToolset.Mba.Core | |||
1693 | 1659 | ||
1694 | int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) | 1660 | int IBootstrapperApplication.OnApplyBegin(int dwPhaseCount, ref bool fCancel) |
1695 | { | 1661 | { |
1696 | this.applying = true; | ||
1697 | |||
1698 | ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); | 1662 | ApplyBeginEventArgs args = new ApplyBeginEventArgs(dwPhaseCount, fCancel); |
1699 | this.OnApplyBegin(args); | 1663 | this.OnApplyBegin(args); |
1700 | 1664 | ||
@@ -1949,8 +1913,6 @@ namespace WixToolset.Mba.Core | |||
1949 | ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); | 1913 | ApplyCompleteEventArgs args = new ApplyCompleteEventArgs(hrStatus, restart, recommendation, pAction); |
1950 | this.OnApplyComplete(args); | 1914 | this.OnApplyComplete(args); |
1951 | 1915 | ||
1952 | this.applying = false; | ||
1953 | |||
1954 | pAction = args.Action; | 1916 | pAction = args.Action; |
1955 | return args.HResult; | 1917 | return args.HResult; |
1956 | } | 1918 | } |
diff --git a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs index d79ac402..be113700 100644 --- a/src/api/burn/WixToolset.Mba.Core/EventArgs.cs +++ b/src/api/burn/WixToolset.Mba.Core/EventArgs.cs | |||
@@ -217,32 +217,6 @@ namespace WixToolset.Mba.Core | |||
217 | } | 217 | } |
218 | 218 | ||
219 | /// <summary> | 219 | /// <summary> |
220 | /// Event arguments for <see cref="IDefaultBootstrapperApplication.SystemShutdown"/> | ||
221 | /// </summary> | ||
222 | [Serializable] | ||
223 | public class SystemShutdownEventArgs : CancellableHResultEventArgs | ||
224 | { | ||
225 | /// <summary /> | ||
226 | public SystemShutdownEventArgs(EndSessionReasons reasons, bool cancelRecommendation) | ||
227 | : base(cancelRecommendation) | ||
228 | { | ||
229 | this.Reasons = reasons; | ||
230 | } | ||
231 | |||
232 | /// <summary> | ||
233 | /// Gets the reason the application is requested to close or being closed. | ||
234 | /// </summary> | ||
235 | /// <remarks> | ||
236 | /// <para>To prevent shutting down or logging off, set <see cref="CancellableHResultEventArgs.Cancel"/> to | ||
237 | /// true; otherwise, set it to false.</para> | ||
238 | /// <para>If <see cref="SystemShutdownEventArgs.Reasons"/> contains <see cref="EndSessionReasons.Critical"/> | ||
239 | /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other | ||
240 | /// critical operations before being closed by the operating system.</para> | ||
241 | /// </remarks> | ||
242 | public EndSessionReasons Reasons { get; private set; } | ||
243 | } | ||
244 | |||
245 | /// <summary> | ||
246 | /// Event arguments for <see cref="IDefaultBootstrapperApplication.DetectBegin"/> | 220 | /// Event arguments for <see cref="IDefaultBootstrapperApplication.DetectBegin"/> |
247 | /// </summary> | 221 | /// </summary> |
248 | [Serializable] | 222 | [Serializable] |
diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs index 2877d4de..8ce99808 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperApplication.cs | |||
@@ -51,19 +51,6 @@ namespace WixToolset.Mba.Core | |||
51 | int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); | 51 | int OnShutdown(ref BOOTSTRAPPER_SHUTDOWN_ACTION action); |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// See <see cref="IDefaultBootstrapperApplication.SystemShutdown"/>. | ||
55 | /// </summary> | ||
56 | /// <param name="dwEndSession"></param> | ||
57 | /// <param name="fCancel"></param> | ||
58 | /// <returns></returns> | ||
59 | [PreserveSig] | ||
60 | [return: MarshalAs(UnmanagedType.I4)] | ||
61 | int OnSystemShutdown( | ||
62 | [MarshalAs(UnmanagedType.U4)] EndSessionReasons dwEndSession, | ||
63 | [MarshalAs(UnmanagedType.Bool)] ref bool fCancel | ||
64 | ); | ||
65 | |||
66 | /// <summary> | ||
67 | /// See <see cref="IDefaultBootstrapperApplication.DetectBegin"/>. | 54 | /// See <see cref="IDefaultBootstrapperApplication.DetectBegin"/>. |
68 | /// </summary> | 55 | /// </summary> |
69 | [PreserveSig] | 56 | [PreserveSig] |
diff --git a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs index 77089e83..2535f756 100644 --- a/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs +++ b/src/api/burn/WixToolset.Mba.Core/IDefaultBootstrapperApplication.cs | |||
@@ -419,22 +419,6 @@ namespace WixToolset.Mba.Core | |||
419 | event EventHandler<SystemRestorePointCompleteEventArgs> SystemRestorePointComplete; | 419 | event EventHandler<SystemRestorePointCompleteEventArgs> SystemRestorePointComplete; |
420 | 420 | ||
421 | /// <summary> | 421 | /// <summary> |
422 | /// Fired when the system is shutting down or user is logging off. | ||
423 | /// </summary> | ||
424 | /// <remarks> | ||
425 | /// <para>To prevent shutting down or logging off, set <see cref="CancellableHResultEventArgs.Cancel"/> to | ||
426 | /// true; otherwise, set it to false.</para> | ||
427 | /// <para>By default setup will prevent shutting down or logging off between | ||
428 | /// <see cref="IDefaultBootstrapperApplication.ApplyBegin"/> and <see cref="IDefaultBootstrapperApplication.ApplyComplete"/>. | ||
429 | /// Derivatives can change this behavior by handling <see cref="IDefaultBootstrapperApplication.SystemShutdown"/>.</para> | ||
430 | /// <para>If <see cref="SystemShutdownEventArgs.Reasons"/> contains <see cref="EndSessionReasons.Critical"/> | ||
431 | /// the bootstrapper cannot prevent the shutdown and only has a few seconds to save state or perform any other | ||
432 | /// critical operations before being closed by the operating system.</para> | ||
433 | /// <para>This event may be fired on a different thread.</para> | ||
434 | /// </remarks> | ||
435 | event EventHandler<SystemShutdownEventArgs> SystemShutdown; | ||
436 | |||
437 | /// <summary> | ||
438 | /// Fired when the engine unregisters the bundle. | 422 | /// Fired when the engine unregisters the bundle. |
439 | /// </summary> | 423 | /// </summary> |
440 | event EventHandler<UnregisterBeginEventArgs> UnregisterBegin; | 424 | event EventHandler<UnregisterBeginEventArgs> UnregisterBegin; |