Home » Visual StudioRSS

Terminate Application from CCR Thread

Hi,

I have application which use CCR thread. I place Causaltiy which catch any unhandled exception.

When that happen I want to terminate the application since it is not a recoverable exception.

I've try doing so by throwing exception from the CCR exception port handler but TaskExecutionWorker.HandleException catch the exception and just log it and the thread terminates, but the application keep on running.

 

I can use Environment.Exit or FailFast but this does not present the user with "we are sorry" message, but close the application without any message which is not good UX.

 

Ido.

 

1 Answer Found

 

Answer 1

This is simply a question of application  design.

Assuming this is a winform application, you need to have an exception  port and listener defined in the form load function.

Arbiter.Activate(new DispatcherQueue(),
	Arbiter.Receive(true, exPort,
          ex => exHandler(ex)));

The exHandler will do whatever you need to do to clean up and play nice with the UI.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter