Last active
January 30, 2020 21:03
-
-
Save GeorgDangl/b40a23b441be1575ac169d99d11e9f44 to your computer and use it in GitHub Desktop.
Workaround to accessing the Revit API from other threads, see https://blog.dangl.me/archive/accessing-the-revit-api-in-callbacks-from-other-threads/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callbackStack = new Stack<Action>(); | |
uiapp.Idling += (s, e) => | |
{ | |
if (callbackStack.Any()) | |
{ | |
var action = callbackStack.Pop(); | |
action.Invoke(); | |
} | |
}; | |
JavaScriptBridge | |
.Instance | |
.OnWebUIMessageReveived += (s, e) => | |
{ | |
callbackStack.Push(() => | |
{ | |
// You can safely access the Revit API here | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JavaScriptBridge | |
.Instance | |
.OnWebUIMessageReveived += (s, e) => | |
{ | |
// Accessing the Revit API here fails | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment