Skip to content

Commit 69c0521

Browse files
author
Dan Walmsley
committed
Add methods for dispatching exceptions on osx.
1 parent c357558 commit 69c0521

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/Avalonia.Native/CallbackBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ protected virtual void Destroyed()
8080

8181
public void RaiseException(Exception e)
8282
{
83-
var exceptionInfo = ExceptionDispatchInfo.Capture(e);
83+
var threadingInterface = AvaloniaLocator.Current.GetService<PlatformThreadingInterface>();
8484

85-
PlatformThreadingInterface.s_exceptionDispatchInfo = exceptionInfo;
85+
threadingInterface.TerminateNativeApp();
86+
87+
threadingInterface.DispatchException(ExceptionDispatchInfo.Capture(e));
8688
}
8789
}
8890
}

src/Avalonia.Native/PlatformThreadingInterface.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ namespace Avalonia.Native
1313
{
1414
public class PlatformThreadingInterface : IPlatformThreadingInterface
1515
{
16-
public static ExceptionDispatchInfo s_exceptionDispatchInfo;
17-
1816
class TimerCallback : CallbackBase, IAvnActionCallback
1917
{
2018
readonly Action _tick;
@@ -46,6 +44,7 @@ public void Signaled(int priority, bool priorityContainsMeaningfulValue)
4644
}
4745

4846
readonly IAvnPlatformThreadingInterface _native;
47+
private ExceptionDispatchInfo _exceptionDispatchInfo;
4948

5049
public PlatformThreadingInterface(IAvnPlatformThreadingInterface native)
5150
{
@@ -86,15 +85,23 @@ public void RunLoop(CancellationToken cancellationToken)
8685
}
8786
}
8887

89-
if(s_exceptionDispatchInfo != null)
88+
if(_exceptionDispatchInfo != null)
9089
{
91-
// TODO terminate NSApp.
92-
93-
s_exceptionDispatchInfo.Throw();
90+
_exceptionDispatchInfo.Throw();
9491
}
9592
}
9693
}
9794

95+
public void DispatchException (ExceptionDispatchInfo exceptionInfo)
96+
{
97+
_exceptionDispatchInfo = exceptionInfo;
98+
}
99+
100+
public void TerminateNativeApp()
101+
{
102+
103+
}
104+
98105
public void Signal(DispatcherPriority priority)
99106
{
100107
_native.Signal((int)priority);

0 commit comments

Comments
 (0)