Skip to content

Commit

Permalink
[SharpDX] Add a private exception to get the stacktrace in ObjectTrac…
Browse files Browse the repository at this point in the history
…ker. Related to issue sharpdx#575,
  • Loading branch information
xoofx committed Jun 10, 2015
1 parent ca4bc4e commit 330f9b4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Source/SharpDX/Diagnostics/ObjectTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ public static void Track(ComObject comObject)
}
referenceList.Add(new ObjectReference(DateTime.Now, comObject, stacktrace));
#else
// Another WTF: To get a stacktrace, we don't have other ways than throwing an exception on PCL.
try
{
throw new Exception();
throw new GetStackTraceException();
}
catch(Exception ex)
catch (GetStackTraceException ex)
{
referenceList.Add(new ObjectReference(DateTime.Now, comObject, ex.StackTrace));
}
Expand Down Expand Up @@ -337,5 +338,9 @@ private static void OnUnTracked(ComObject obj)
handler(null, new ComObjectEventArgs(obj));
}
}

private class GetStackTraceException : Exception
{
}
}
}

0 comments on commit 330f9b4

Please sign in to comment.