무겁게 javascripted 될 Silverlight 응용 프로그램을 만들고 있습니다. 이것은 자바 스크립트와 같이,Javascript/Silverlight 프록시 이중로드 지연
public App()
{
this.Startup += this.onStartup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
// register javascript bridge proxy
// (must register in constructor so proxy is available immediatly)
HtmlPage.RegisterScriptableObject("JsProxy", new JavaScriptProxy());
}
그러나 :
, 내가 만든 다음 SL 클래스 JS 상호 작용을 활성화하려면 :[ScriptableType]
public class JavaScriptProxy
{
private string _version;
// provided for testing SL-JS integration
[ScriptableMember]
public void SmokeTest() { HtmlPage.Window.Alert("Hello world!"); }
}
을 그리고 주요 SL 응용 프로그램의 생성자에로드 - 무거운 애플 리케이션, 그것은 자바 스크립트 자체를 통해로드 할 수 있어야합니다.
e.e. 뭔가 alongs는 : agApp.Content.JsProxy
는 실버 onLoad 이벤트가 트리거 될 때까지, 따라서 JsProxy 필드를 사용할 수없는 완전히 사용할 수 없기 때문에
// called on body.onLoad
function init() {
var proxy;
var el = document.getElementById("target_canvas");
Silverlight.createObject(..., el, "agApp" ..., {
onLoad: function() {
proxy = agApp.Content.JsProxy;
// ***this line is ok***
proxy.SmokeTest();
}
});
// ***this line fails (of course)***
proxy.SmokeTest();
}
그러나이 오류를 올립니다. 내가 실버 인스턴스를 만들 때
어떻게 JsProxy 클래스 즉시에 액세스 할 수 있도록 할 수 있습니까? 어떤 일이있는 동안 while (_mutex); 아마도 나쁜 생각 일 것입니다.
실버 라이트 앱 인스턴스 생성시 다른 추상화 계층이있을 것이므로이 기능을 사용하여 모든 SL 콘텐츠를 한 번에 동 기적으로로드해야합니다.