locked
Concurrent file write access when app is started for 2 different activation events

    Question

  • My app can be started via launch contract (obviously) and also via fileOpenPicker activation.

    When my app is started I create a logfile in "ms-appdata://local/logs/log.txt" and keep that file open for faster writes.

    The second instance of the app that is started cannot open the same file for writing. Is there a shared write mode available in WinRT? Or should I create a logfile for each activation method like "launch.log" and "fileOpenPicker.log"? Since I assume there can be only one instance of the app open for any activation method?

    Saturday, March 22, 2014 12:56 AM

All replies

  • My app can be started via launch contract (obviously) and also via fileOpenPicker activation.

    When my app is started I create a logfile in "ms-appdata://local/logs/log.txt" and keep that file open for faster writes.

    The second instance of the app that is started cannot open the same file for writing. Is there a shared write mode available in WinRT? Or should I create a logfile for each activation method like "launch.log" and "fileOpenPicker.log"? Since I assume there can be only one instance of the app open for any activation method?

    Saturday, March 22, 2014 1:01 AM
  • There is actually only one instance of the app running, so if the app is already running with PID X and there is a URL activation, PID X will get called, there won't be PID Y getting launched for the same app. I believe you are trying to create a file - which already exists and is been opened. Maybe you can have a variable that gets set when the file is created, that way you can check the variable to see if it is already set (meaning app is launched) to decide whether to create a file or just append to an existing file...

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Saturday, March 22, 2014 1:17 AM
    Moderator
  • hmmm my post was submitted twice it seems.

    In the debugger I saw 2 instances of wwahost.exe running. And that is only logical I think. First instance was the once that i launched from the start menu. The second instance was from the file picker. 2 instances run at the same time (with the background instances being suspended after some time). My scenario is not URL activation but file picker. With URL activation there is only one instance, i know. 

    I open the file with collision option "openIfExist", so that is not the problem.

    Saturday, March 22, 2014 3:45 AM
  • I tried using the "Association Launching sample" and I cannot see the two instances of the app created. If you have a repro of the two app scenario, please share it on OneDrive.

    As far as the repro steps go, I launched the Association Launching sample from the Start screen and in Scenario 1, I choose the "Pick and Launch" option to open the File Open picker. In the file open dialog, I choose a file called "test.alsdkjs". When the file gets chosen, the same app gets notified and gets navigated to scenario 3, "Receiving a file".

    If you can repro the issue with the association launching sample, please share the repro steps too.

    Here's the link to the sample: http://code.msdn.microsoft.com/windowsapps/Association-Launching-535d2cec


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Monday, March 24, 2014 10:14 PM
    Moderator