Created
August 27, 2012 20:35
-
-
Save timheuer/3492033 to your computer and use it in GitHub Desktop.
Async Void method from JavaScript
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
function dostuff() { | |
var j = document.getElementById("mycontent"); | |
j.innerText = ""; | |
var b = new WindowsRuntimeComponent6.Class1(); | |
var c = b.initializeAsync().done(onStuffComplete, onStuffError); | |
} | |
function onStuffComplete() { | |
var j = document.getElementById("mycontent"); | |
j.innerText = "the function completed"; | |
} | |
function onStuffError() { | |
var j = document.getElementById("mycontent"); | |
j.innerText = "the function had an error"; | |
} |
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
public IAsyncAction InitializeAsync() | |
{ | |
return AsyncInfo.Run(async delegate | |
{ | |
var storagefile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"WindowsRuntimeComponent6\TextFile1.txt"); | |
using (var strm = await storagefile.OpenStreamForReadAsync()) | |
{ | |
using (StreamReader rdr = new StreamReader(strm)) | |
{ | |
string data = rdr.ReadToEnd(); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment