I tested a simple asynchronous FormRegionShowing event handler
private async void MyForm_FormRegionShowing(object sender, System.EventArgs e)
{
await Task.Delay(3000);
}
When I debug this code in VS and await command works OK. FormRegionShowing event fires only once and only one MyForm instance is shown in email preview pane. However, when add-in is installed on test machine by add-in's setup program, FormRegionShowing event fires twice. As a result, two MyForm's are shown in preview pane. I attached Visual Studio 2015 debugger to OUTLOOK process and this is what I figured out. When event fires first time, the program leaves MyForm_FormRegionShowing method after it hits await Task.Delay(3000) command. Immediately after that, FormRegionShowing event fires second time. In this time, await Task.Delay(3000) command completes. But, because event was fired twice two MyForm instances are shown in email preview pane. Do you know why this happens? Thank you.
Looks like the add-in or the pane was registered twice on the end user machine. I'd recommend creating a new sample add-in from scratch to make sure the issue doesn't depend on the pane or add-in.
Related
I created an app using Xamarin.Forms. I am trying to detect if there is a change in phone's language each time the app is reopened after being closed using the back button. Tried to Debug.WriteLine on each of onStart, onSleep and onResume to see which one occurs when I open the app again but none of them worked. This is what i tried:
App.xaml.cs
protected override void OnStart()
{
Debug.WriteLine("onresume");
//CultureInfo language = CultureInfo.InstalledUICulture;
//Thread.CurrentThread.CurrentUICulture = language;
//ApplicationResource.Culture = language;
//Application.Current.MainPage = new NavigationPage(new MainPage());
}
protected override void OnSleep()
{
Debug.WriteLine("onsleep");
}
protected override void OnResume()
{
Debug.WriteLine("onresume");
}
How do I know when the app is reopened so I could try the language change code?
If i understand your concern correctly two things can help you:
On android you can have a very wierd behavour if you do not specify SingleTask for your mainactivty. Basically if you "close" the app using Back button and then click on app icon, the app is launched from start recreating App but keeps static variables and the debugger is still connected too. You can detect it setting a static variable, then checking it with a breakpoint inside App.cs constructor. So the avoid such just use LaunchMode = LaunchMode.SingleTask inside the MainActivity.cs [Activity] attribute. This way after you return to the app after the Back button + click on icon you'll get a fresh new app with OnStart invoked.
Some could say to use LaunchMode.SingleInstance but it will kill your app if you click on push notification whie app is active so better use SingleTask, it will open smoothly the running app.
To store and retrieve data between app launches use local persistent storage, full docs: https://learn.microsoft.com/en-us/xamarin/essentials/preferences?tabs=android. So when you got your language store it, then at app start (App.cs constructor) check values.
I had done a simple to test your code with the Android simulator. And I use the Console.WriteLine instead of the Debug.WriteLine.
I had found that:
When the app exited with the back button, it will call the OnSleep method and if you get into the app in the recent task, it will call the OnStart method.
When the app go to background with the home button, it will call the OnSleep methed too, but if you get into the app in the recent task, it will call the OnResume method.
So if you add a break point in the OnStart method, when you exit with the back button and get into the app again, it will hit the break point.
Every time the Watch receives a notification (let's say local), either the static long look or the dynamic long look interface is loaded.
However, what I am observing is that every time the corresponding watch app's first interface controller is also getting loaded.
Is it something that other people have also observed?
Every time the Watch receives a notification, the watch app's first interface controller also gets run behind the scenes.
If it really does, how to distinguish when the watch app ran because user opened it and when it ran because there was a notification that came? context in awakeWithContext: is null in both cases.
Yes, I noticed too. It also seems it is in charge to handle the action methods for for local and remote Notification when tap on a button:
handleActionWithIdentifier:forLocalNotification:
I think you can use:
didReceiveRemoteNotification:withCompletion:
or
didReceiveLocalNotification::withCompletion:
to detect when your app is populated from a remote or local notification
As of watchOS 3 you can out exit of awake(withContext:) early in this scenario by inspecting the applicationState of your extension:
override func awake(withContext context: Any?) {
if #available(watchOS 3.0, *) {
if WKExtension.shared().applicationState == .background {
print("Awake with Context in background. Not processing.")
return
}
}
// otherwise, load normally
}
In my ASP.net application, i have to open a EXE on click of button. When the EXE is open, User should not be allowed to perform any action on the web form, i.e. the exe should behave like a modal popup. I am using the current code to open and return value from EXE.
Dim p As Process
p = Process.Start("D:\VS2010Projects\SignatureCaptureWindows\bin\Debug\SignatureCaptureWindows.exe")
p.WaitForExit()
If (Not p.ExitCode.Equals(0)) Then
Response.Write("Image Successfully saved in Database with ID = " + p.ExitCode.ToString())
DisplaySavedImage(p.ExitCode)
End If
The Exe is opening fine and returning the correct value. However, the user is able to perform action on the web form when the exe is open...
What will be the best way to handle such a scenario ??
Its impossible to do the way you won it. From the moment the user send a submit, or try to open the page, and on code behind you run this exe, then user is wait for the results - in this time you can not make the user to not do anything else - you can not lock the browser, user can close it, reload it, open again the same page, etc.
What you can do is to lock this process using Mutex and not allow to run again if all ready run it.
Mutex on msdn with example : http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx
I am working on web application , in my project there is some type of testing and task assignment to employees.
Now when an employee complete a task and assigned to a user the user automatically get the message on his page ( there is 3 user accessing application , one is admin , second is tester and third is verifier ...both of them works on different pages , now when admin assign a task the tester automatically get a notification " new message " ( for this i am using master page)..on whatever page the tester is on working... now if the tester is completes it 's task and assign to verifier , verifier must get notification "new message" ... and so on..)
for this a have put a button on master page ..and also i have make a windows service that runs on every minute , now my problem is how i sent the message from windows service to my master page button ( that i change text of button).
Is this idea working ?
Why do you need to window service to run in background? Is there any specific reason to have the windows service for these requirements?
As per your detailed description what I understood is that when the employee completes a task and assigned to a user the user automatically get the message on his page. So when the employee is working and completed means they will click on some button that their work is completed. Then while clicking on the button, you just write the code for sending the mail to the tester. like the same way, when the tester is completed their work and click on the testing completes, send a mail to the reviewer and so on..Then where is the need to have a window service for this to send the mails?
All the requirements can be achieved through the simple send mail code.
Let us know if you need any more help or if you don't understand the exact scenario or if anything is missing in the requirements.
Hope it will be helpful to you.
I don't think it is possible to send from a windows service informations to asp.page. You can create a button that can query a webservice about new tasks (but you are counting on the user to press it).
Another more "friendly" way is to have a timer in javascript that uses ajax requests to get new tasks.
is it possible to stop a web service from executing?
I have a flex web application that searches clients with both full name and client id, when searching by name sometimes the usuer just types the last name and it takes a long time.
Since the app is used when clients are waiting in line, I would like to be able to stop the search and use their full name or id instead, and avoid waiting for the results and then having to search the user manually within the results.
thanks
edit: Sorry, I didn't explain myself correctly, when I meant "web service" I actually meant mx.rpc.soap.mxml.WebService, I want to stop it from waiting for the result event and the fault event. thanks.
There is actually a cancel(..) method explicitly for this purpose, though it is a little burried. Using the cancel method will cause the result and fault handlers not to be called and will also remove the busy cursor etc.
Depending on how you run your searches (ie. separate worker process etc), it is also possible to extend this by added in a cancelSearch() web service method to kill these worker processes and free up server resources etc.
private var _searchToken:AsyncToken;
public function doSearch(query:String):void
{
_searchToken = this.searchService.doSearch(query);
}
protected function doSearch_resultHandler(event:ResultEvent):void
{
trace("doSearch result");
trace("TODO: Do stuff with results");
_searchToken = null;
}
protected function doSearch_faultHandler(event:FaultEvent):void
{
trace("doSearch fault: " + event.fault);
_searchToken = null;
}
public function cancelSearch():void
{
var searchMessageId:String = _searchToken.message.messageId;
// Cancels the last service invocation or an invokation with the
// specified ID. Even though the network operation may still
// continue, no result or fault event is dispatched.
searchService.getOperation("doSearch").cancel(searchMessageId);
_searchToken = null;
trace("The search was cancelled, result/fault handlers not called");
// TODO: If your web service search method is using worker processes
// to do a search and is likely to continue processing for some time,
// you may want to implement a 'cancel()' method on the web service
// to stop any search threads that may be running.
}
Update
You could use disconnect() to remove any pending request responders, but it also disconnects the service's connection. Then call initialize().
/Update
You cannot stop the web service from executing, because that's beyond the Flex app's control, but you can limit the processing of the web service's response. For instance on the app, have a button like Cancel Search which sets a boolean bSearchCanceled to true.
The result handler for the web service call checks bSearchCanceled; if true just return.