ASP.NET MVC3 how to wait for async call back and return result
Tag : chash , By : Jenuel
Date : March 29 2020, 07:55 AM
it should still fix some issue Background: public Task<UserInfo> KickOffWarmUpCache(string id)
{
//If Status = Progress
if (cache.Get(id).Status == "Progress")
{
var ret = new TaskCompletionSource<UserInfo>();
NotifyOnceCacheIsUpdated(id,(result)=>
{
//complete the task.
ret.SetResult(result.userInfo);
});
//return a Task...which the SetResult will complete.
return ret.Task;
}
//Return a result synchronously
return Task.FromResult(Cache.Get(id));
}
|
Is there a way to trigger an event through a listener from a parse push notification instead of showing a notification t
Date : March 29 2020, 07:55 AM
This might help you Sure, you can do this with a combination of push notifications and their proper handlers. Send the push as a silent push. As noted in this SO post, silent push reception is the default- you have to add extra code to interact with the user. When you receive it, process it appropriately to run background code instead of interacting with the user. You can read more about how to receive and process a push in the Parse.com Push Guide for Android.
|
Wait for Listener to finish the task and get result for another function [Android]
Date : March 29 2020, 07:55 AM
like below fixes the issue I want to get a file path from my file browser function, but my file browser function has listener, so if i call another function after this file explorer function, it become crash because the path is still empty, here's two function that i want to call : , call generateMFCC from openFileExplorer only. public void openFileExplorer() {
File mPath = new File(Environment.getExternalStorageDirectory() + "/");
fileDialog = new FileDialog(this, mPath);
fileDialog.addFileListener(new FileDialog.FileSelectedListener() {
public void fileSelected(File file) {
Log.d(getClass().getName(), "selected file " + file.toString());
chosenFile = file.toString();
generateMFCC(chosenFile);
}
});
fileDialog.showDialog();
}
|
wait for async call to finish before firing function in event listener
Date : March 29 2020, 07:55 AM
Does that help As explained in this answer: https://stackoverflow.com/a/22125915/5721273 I could use a setTimeout within the plugins, to continuously poll for changes on a flag set by the ajax call completion. function checkFlag() {
if(flag == false) {
window.setTimeout(checkFlag, 100); /* this checks the flag every 100 milliseconds*/
} else {
/* do something*/
}
}
checkFlag();
|
Event Listener call back function not called
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , postMessage sends a message event, not an onWidgetDisplayed event, so you'd want to hook the message event. If you need to send multiple types of messages, you can pass any arbitrary JavaScript value as the event data. You're already passing a string, so: window.addEventListener("message", function(e) {
if (/* check `e.origin` and make sure you're happy with it*/) {
if (e.data === "onWidgetDisplayed") {
onWidgetDisplayed.call(this, e);
}
}
}, false);
|