Restart WPF Application - wpf

My application has many views and I am using an AutoLogoffHelper class which maintains the timer for the application. Due to inactivity if the timer is 0, it call the log off event (which is also in the AutoLogoffhelper class).
As of now I am using Application.shutdown to completely shutdown the Application.
But Is there a way to restart the application or delete navigation history and session information and navigate to login screen?
Thanks.

To restart you can use Process.Start and the command line args (which automatically contain the application's path):
Process.Start(Environment.GetCommandLineArgs()[0]);

Related

app should not give service call in background mode

I have built an application in codename one . I want A Scenerio where if my app runs in background on device then it should not give call to the service .it should call only if user opens the application.
Check out the developer guide for details on background execution. Generally an app can't do "anything" in the background and has a lot of restrictions when it comes to that.

Is it possible to open a web page from a Cortana background app?

Cortana background apps provide deep linking capabilities, which allow the developer to link to a specific page within her app. I'm wondering if it's possible to open a different application instead, for example a web browser.
My current work-around is to deep-link into my app, and then call Windows.System.Launcher.launchUriAsync as soon as my app is launched. However, this means that the app opens along of the web browser. I would like it to not open at all! Is that possible?
From the MSDN page for LaunchUriAsync:
Unless you are calling this API from a Classic Windows application, this API must be called from within an ASTA thread (also known as a UI thread).
Unfortunately, Cortana's background task is not a UI thread. You're running as a background task, and communicating to Cortana's UI via a set of APIs provided for that purpose, which are limited by design.
Anything you try to do that requires you to be in the UI thread is going to fail for the same reason. You could try hosting the web control in your app however to remove the chain-launched browser from the equation.

Win 8.1 Universal app - App Exit on Fast App Switching

I am developing an app for Windows Universal 8.1, facing an issue where the App gets Exit on going background. The scenarios are as follows
When the app goes background on clicking Windows key(FAS), the app get exit.
When I launch Share Task i.e Data Transfer Manager Interface, after completing the share operation the app exit.
Works fine in Debug mode but issue found after deploying to the device.
PS : I am using the Navigation Service Interface to navigate to pages using MVVM and navigating from viewmodels.
Please help if its known issue, if not help to rectify this.
Thanks in advance.
Sounds like your App crashes in The Suspending Event. As apps in Debug mode are not suspended, you are unlikely to see that happen.
You can manually fire the event from Visual Studio when debugging: It is in the debugging toolbar under Application Lifecycle Events.
Most common error in this case: Using complex objects as navigation parameters, which cannot be serialized.

Selenium IE webdriver - how to cope when the application closes the browser window and launches a new one?

I have an instance where user try to log-in application (simple webpage). After successful log in, the application closes the current page and open a new webpage. Rest of the business operations start from there.
Till the point API clicks log-in button, everything goes fine. After log in (once the log in webpage closes and a new session gets opened), the API throws "Unable to find browser". This is true as the original driver instance has been closed by the application.
Is there a way to achieve these kind of scenarios using selenium, as they are very common now-a days in a typical business application.
Thanks.
If you need to driver a different browser window or iframe, you need to use switchto. From the WebDriver faq:
Q: How do I handle pop up windows?
A: WebDriver offers the ability to cope with multiple windows. This is done by using the "WebDriver.switchTo().window()" method to switch to a window with a known name. If the name is not known, you can use "WebDriver.getWindowHandles()" to obtain a list of known windows. You may pass the handle to "switchTo().window()".
Thanks for the Answer.
I did the below to achieve my query.
Execute a javascript to open a new window.
IJavaScriptExecutor jScript = driver as IJavaScriptExecutor;
jScript.ExecuteScript("window.open()");
Switch to the newly opened window.
List<string> handles = driver.WindowHandles.ToList<string>();
driver.SwitchTo().Window(handles.Last());
Start the Navigate and Login operation on the new window
driver.Navigate().GoToUrl("Your website");
After login, the application will close the new window but the main driver window will still be alive.
Implement a simple SwitchTo() for the new window to start new business operations
List<string> handles = driver.WindowHandles.ToList<string>();
driver.SwitchTo().Window(handles.Last());

Application restarting after going to home screen

I have an android app designed using codename one
1)I run my application
2)I click on the home button of the phone.My app is taken away from my app and home screen is shown to me.
3)I again click on my application after navigating to it from the menu.
I expect that the state of my application be restored. But what happens is, my application restarts.
Also, this behaviour is arbitrary. Sometimes the application restarts and at other times the application resumes its state. Most of the times it restarts.
How do i ensure that my application always resumes its old state?
Android restarts running applications on some conditions to preserve RAM, battery etc. If you use the task switcher the application will resume properly but relaunching it often restarts it.
We are working on improving this behavior in the next update to Codename One, but you can use the stop method to store the application state into storage and use the start method to restore the application state.

Resources