

Public NotInheritable Class ApplicationClosingEvent Inherits ArcGIS.Core.Events.AsyncPresentationEvent(Of CancelEventArgs)
public sealed class ApplicationClosingEvent : ArcGIS.Core.Events.AsyncPresentationEvent<CancelEventArgs>
{
// There are two ways to prevent ArcGIS Pro from closing
// 1. Override the CanUnload method on your add-in's module and return false.
// 2. Subscribe to the ApplicationClosing event and cancel the event when you receive it
// 1. Override the CanUnload method on your add-in's module and return false.
// Called by Framework when ArcGIS Pro is closing
{
//return false to ~cancel~ Application close
}
{
// 2. Subscribe to the ApplicationClosing event and cancel the event when you receive it
// Replace this line:
// ArcGIS.Desktop.Framework.Events.ApplicationClosingEvent.Subscribe(() => { });
// With the following, which matches the required delegate signature:
ArcGIS.Desktop.Framework.Events.ApplicationClosingEvent.Subscribe((args) =>
{
//Do something here, e.g. prompt user to save work
return Task.CompletedTask;
}
);
// in the Application Closing event handler set the Cancel property of the event args to true to prevent Pro from closing
}
}
// Called by Framework when ArcGIS Pro is closing
{
ArcGIS.Desktop.Framework.Events.ApplicationClosingEvent.Subscribe((args) =>
{
//Do something here, e.g. prompt user to save work
return Task.CompletedTask;
}
);
}
System.Object
ArcGIS.Core.Events.EventBase
ArcGIS.Core.Events.AsyncPresentationEvent<TPayload>
ArcGIS.Desktop.Framework.Events.ApplicationClosingEvent
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)