Javascript 我可以从Windows 10(UWP)应用程序中的web worker调用自定义运行时组件吗
我们计划用JavaScript为Windows 10编写一个通用Windows平台应用程序 我们还需要编写一些定制的运行时组件,最有可能是C语言 我知道可以从主UI线程调用自定义运行时组件。现在的问题是: 在中,是否可以从Web工作者中调用自定义运行时组件 它是否需要一些特殊的配置/设置/api 谢谢! 胡安 是否可以从Web Worker中调用自定义运行时组件 我做了一个基本的演示。自定义运行时组件对于Web Worker非常有效 我所做的:Javascript 我可以从Windows 10(UWP)应用程序中的web worker调用自定义运行时组件吗,javascript,c#,windows-10,uwp,web-worker,Javascript,C#,Windows 10,Uwp,Web Worker,我们计划用JavaScript为Windows 10编写一个通用Windows平台应用程序 我们还需要编写一些定制的运行时组件,最有可能是C语言 我知道可以从主UI线程调用自定义运行时组件。现在的问题是: 在中,是否可以从Web工作者中调用自定义运行时组件 它是否需要一些特殊的配置/设置/api 谢谢! 胡安 是否可以从Web Worker中调用自定义运行时组件 我做了一个基本的演示。自定义运行时组件对于Web Worker非常有效 我所做的: 我创建了一个自定义运行时组件,并在基于js的UWP
public sealed class Example
{
public static string GetAnswer()
{
return "This is Answer";
}
}
// Your code here!
(function () {
"use strict"
var w;
if (typeof Worker !== "undefined")
{
var w = new Worker("ms-appx:///js/webWorkerDemo.js");
w.onmessage = function (evt)
{
document.getElementById("myContent").innerText = evt.data;
w.terminate();
}
}
})();
public sealed class Example
{
public static string GetAnswer()
{
return "This is Answer";
}
}
// Your code here!
(function () {
"use strict"
var w;
if (typeof Worker !== "undefined")
{
var w = new Worker("ms-appx:///js/webWorkerDemo.js");
w.onmessage = function (evt)
{
document.getElementById("myContent").innerText = evt.data;
w.terminate();
}
}
})();
并将myContent div放入index.html:
<body>
<div id="myContent"></div>
<script src="js/main.js"></script>
</body>
public sealed class Example
{
public static string GetAnswer()
{
return "This is Answer";
}
}
// Your code here!
(function () {
"use strict"
var w;
if (typeof Worker !== "undefined")
{
var w = new Worker("ms-appx:///js/webWorkerDemo.js");
w.onmessage = function (evt)
{
document.getElementById("myContent").innerText = evt.data;
w.terminate();
}
}
})();
public sealed class Example
{
public static string GetAnswer()
{
return "This is Answer";
}
}
// Your code here!
(function () {
"use strict"
var w;
if (typeof Worker !== "undefined")
{
var w = new Worker("ms-appx:///js/webWorkerDemo.js");
w.onmessage = function (evt)
{
document.getElementById("myContent").innerText = evt.data;
w.terminate();
}
}
})();
并将myContent div放入index.html:
<body>
<div id="myContent"></div>
<script src="js/main.js"></script>
</body>
这是完整的示例:。非常感谢!这是一个很好的回答。非常感谢!这是一个很好的回答。