You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
// Runs the action on UI thread. Prevents from reentracy.
92
+
publicstaticvoidRun(Actionaction)
93
+
{
94
+
if(isUnitTestingMode)
95
+
{
96
+
action();
97
+
return;
98
+
}
99
+
Debug.Assert(ctxt!=null,"The SynchronizationContext must be captured before calling this method");
100
+
#ifDEBUG
101
+
StackTracestackTrace=newStackTrace(true);
102
+
#endif
103
+
ctxt.Post(delegate(objectignore)
104
+
{
105
+
UIThread.MustBeCalledFromUIThread();
106
+
ourUIQueue.Enqueue(action);
107
+
if(ourIsReentrancy)return;
108
+
ourIsReentrancy=true;
109
+
try
110
+
{
111
+
while(ourUIQueue.Count>0)
112
+
{
113
+
try
114
+
{
115
+
vara=ourUIQueue.Dequeue();
116
+
a();
117
+
}
118
+
#ifDEBUG
119
+
catch(Exceptione)
120
+
{
121
+
// swallow, random exceptions should not kill process
122
+
Debug.Assert(false,string.Format("UIThread.Run caught and swallowed exception: {0}\n\noriginally invoked from stack:\n{1}",e.ToString(),stackTrace.ToString()));
123
+
}
124
+
#else
125
+
catch(Exception){
126
+
// swallow, random exceptions should not kill process
127
+
}
128
+
#endif
129
+
130
+
}
131
+
}
132
+
finally
133
+
{
134
+
ourIsReentrancy=false;
135
+
}
136
+
},null);
137
+
138
+
}
139
+
140
+
/// <summary>
141
+
/// RunSync puts orignal exception stacktrace to Exception.Data by this key if action throws on UI thread
142
+
/// </summary>
143
+
/// WrappedStacktraceKey is a string to keep exception serializable.