What could prevent a ScheduledTaskAgent from firing OnInvoke more than once? - windows-phone-8

I have set up a ScheduledTaskAgent with a LaunchForTest (which I know is being called). When I launch the main app, it seems to successfully add the task and OnInvoke runs to completion (calls NotifyComplete), but never seems to run again. I've pared down the OnInvoke to do nothing other than call NotifyComplete, but it still only ever runs the one time following ScheduledActionService.Add and ScheduledActionService.LaunchForTest (with a few seconds' delay).
What could be preventing it from running more than once?

I am assuming it is about PeriodicTask.
You are right. It will run only once and that is because of the LaunchForTest call, wherein you have specified the timespan. After that execution, you have to wait another 30 minutes for it to run.
Are you adding the ScheduledActionService.Add in App.xaml.cs? I mean, on the launch event? You should. If you have that, then you could run the app again, and it will invoke the task agent.

If you are hitting the breakpoint even once that means that you are correctly set up. You have to remember that ScheduledActionService.LaunchForTest is just a function that you can call under debugger. It will not work when the app is released.
Basically, there is no way to fire the background agent, you can register it and then forget it. Windows Phone OS will invoke it periodically.
If you want to debug the periodic task multiple times then you can put LaunchForTest in a loop with delay.

Related

JUnit5: How do I configure a TestExecutionListener to run last?

I have created a TestExecutionListener that wants to persist additional data in the XML files created by the LegacyXmlReportGeneratingListener (you know, the TEST-testClassName.xml ones in /build/test-reports/test).
I have registered the TestExecutionListener via /META-INF/services/org.junit.platform.launcher.TestExecutionListener.
Everything works fine so far, except the fact, that the LegacyXmlReportGeneratingListener runs afterwards and overwrites my changes. Or on a freshly built system, my listener can't - of course - even find the XMLs.
How can I tell my custom listener to run last or at least after the report generating listeners?
Thanks in advance

CreateProcess returns handle different than launched Chrome.exe

I am using CreateProcess and giving Chrome.exe as the argument.
I am getting the handle of the process I created using PROCESS_INFORMATION which internally has hProcess
When I print the PID using GetProcessId(handle) I am getting a different PID than the ones showing in the task manager.
I have tried setting callback function to trigger after Chrome.exe exists, but it triggers anyway. This is expected (not desired) since Chrome.exe PID is different.
It seems like when I use CreateProcess on Chrome.exe, chrome takes liberty to start its own new process and render all my control useless.
I have tried using it with FireFox.exe and it worked well, I got the handle it pointed to the correct process.
Is it not possible to get handles to Chrome processes I spawn?
The Chrome process you are spawning with CreateProcess() is, in turn, spawning its own child process(es) and then terminating itself. Your Firefox is not doing that, at least not initially (Firefox does use child processes for browser tabs - most modern browsers do, for security and stability).
So, the Chrome PID/handle you get from CreateProcess(), albeit valid, is short-lived and clearly useless for your needs.
But, all is not lost. You can get notified about the child PID(s) that Chrome itself spawns. Add your spawned Chrome process to a job object, then use SetInformationJobObject() to assign that job to an I/O completion port, then use GetQueuedCompletionStatus() to receive events from the job, in particular JOB_OBJECT_MSG_NEW_PROCESS whenever a new process is created in the job, and JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO when all processes in the job have ended. See How do I wait until all processes in a job have exited? for more details.

Access Application.Quit not working, SharePoint Web Database

In my database (Access 2013, .accdw), I am checking the user's current version in the Form_Open event. If it is not up to date it triggers an external command to download a fresh copy and then is supposed to close itself to allow for the update. The problem is that after Application.Quit is triggered, access closes but instantly reopens, blocking the download. I've stripped out all the code I can to isolate the problem.
If 1 = 1 Then
Application.Quit
End If
Simplified pretty far, right? It should always just close as soon as the form is opened. With this as the only code in my Form_Open event which is the only code in the form, it still closes, reopens, and then closes again. Docmd.Quit has the same effect. I've tried too many variations to enumerate. In a button this code works fine, but I need it to run the check before it loads any data (the linked tables may be being altered while we change versions).
Any ideas how to make it stay closed the first time it closes?
I think it reopens because your external code (.bat file ?) reopens it. It's not an Access problem. Have you checked the numerous tools you can find for Access automated client deployment ? Here are the first 2 I found:
http://www.databasejournal.com/features/msaccess/article.php/3286111/Automatically-Deploy-a-New-Access-Client.htm
http://www.devhut.net/2015/06/30/ms-access-deploying-your-database-front-end-to-your-users/
Your code works for me in a Form_Open(), but then this is Access 2010 and no Sharepoint.
You may have better luck by Creating an AutoExec macro that calls an initialization function that does the version check, instead of having a form open automatically.
If the version check is ok, then open your start form from the function.
The easy work-around is to always fetch the current version and then launch it.
This way there's no fuzz and the user always run the latest version.

Application_Launching timing

What exactly is the timing/thread of the Application_Launching method on WP8? Specifically, in relation to the UI loading/rendering sequence?
I have an app where some global init is being done within Application_Launching. I'm getting a crash report from a method that's called during data binding on the start page's XAML; the crash is consistent with said global init not taking place.
EDIT: I'm calling a native (C++) method which is reading a file into a mallocated memory block in a global variable that's initialized to null. Said variable is dumped as a part of crash reporting; I've got a report where it's null.
Pasting the code would be rather pointless IMHO.
When starting the app, the Launching event is raised. However, the app can later be put in a dormant state, in a process that is called "tombstoning". When a tombstoned app is resumed, it won't raise the Launching event but the Activated event instead. It's very likely that you forgot to handle that case.
To test it easily, go in the properties of your Windows Phone project, in the Debug tab, and check the "Tombstone upon deactivation while debugging" option. From there, every time the app is deactivated while the debugger is attached (typically, when pressing the home button on the emulator), the app will be tombstoned, and you can make sure that it resumes properly when switching back to it.
I've got another theory. It's not about the library being loaded at the wrong time, it's about the library being unloaded. Since almost all of my native functions are static and the state is global, there are no active native objects, and the COM subsystem has a zero ref count on the module. As per COM rules, modules like that are fair game for unloading anytime. On a subsequent native function call, the library is reloaded, but the global state is gone.
From the next version, I'll keep one live native object for the app's lifetime. We'll see if the crash comes back.

MS Access On_Current event not firing on very first run of the application

I have an MS Access front end application in which the first form to be opened (a splash screen - the form is opened from the Autoexec Macro) has an on_Load event which sets the timer interval to 0, and an on current event which sets it to 100. The timer event starts the application running (attaching to the backend SQL Server Database etc).
When a fresh copy of the application is copied to a new place - we do that when there is a new release - it gets copied to each users machine, the very first call of the application acts as through the timer never fires. In other words it appears the the on current event never fires.
I cannot find what is causing it, and my only explanation that I can think of is that in testing the start up just before release, I have set the form so its current record IS the one that is set when the form loads on start up.
Is this true? Is there a situation anyone is aware of where the on_current event doesn't fire for that, or any other reason.
The reason I wait until the on_current event is that the form itself has a data-source which depending on the form filter sets the parameters for different databases to connect to (production v test for instance). A work around may be to set the timer interval in the on load event - but it opens up to a possible race condition where the timer fires before on_current has set the correct database, and I would prefer to avoid that risk
On Current fires when you move to a new record. To force it to fire, you might try to move to the last record, then back to the first.