SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

FileChangeWatcher blocks application on start-up

Last post 01-13-2015 8:54 PM by Dirkster. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-19-2014 5:57 PM

    FileChangeWatcher blocks application on start-up

    I am trying to port the FileWatcher feature from #SharpDevelop into a WPF application and thought this
    should not be complex if I start adopting the model part and build the viewmodel on it etc...

    https://edi.codeplex.com/SourceControl/latest#Edi.Core/Utillities/FileSystem/PathName.cs

    and this seemed to be a good approach but I found now that the application is sometimes hanging
    on start-up - this problem seems somehow to be due to the FileChangeWatcher class

    https://edi.codeplex.com/SourceControl/latest#Edi.Core/Utillities/FileSystem/FileChangeWatcher.cs

    ...because I never ran into this before but it appeared right after integrating this... The deadlock is so

    bad that I have to re-boot my PC to get rid of the hanging process... and it does not allways happen -
    but it does occur 1 out of 10 times when I have about 10 files open from different locations (network,
    hard disk drives etc).

    So, it looks like I am looking at another threading problem but I cannot seem to be able to resolve it
    (I already spent a day on it).

    The problem can be verified when the code in
    Edi.Core.Models.Documents.DocumentModel.QueryFileProperies():

    https://edi.codeplex.com/SourceControl/latest#Edi.Core/Models/Documents/DocumentModel.cs

    ---------------

    if (this.mFileChangeWatcher != null)
    {
      this.mFileChangeWatcher.Dispose();
      this.mFileChangeWatcher = null;
    }

    this.mFileChangeWatcher = new FileChangeWatcher(this);
    ---------------

    is commented in to activate the FileChangeWatcher and the application is started with a document session
    that has a few documents to be opened on start-up (open application, open multiple documents, shut-down
    application, re-start application).

    My problem in WPF is that I am opening the file on a background thread and I think this is part of the problem
    I just cannot find a concept to ensure the correct thread access because the application either hangs or the
    FileChangeWatcher is just not working :-(

    Does someone have an idea to tackle this with a sound concept in WPF?

  • 01-13-2015 8:54 PM In reply to

    Re: FileChangeWatcher blocks application on start-up

    I found a problem - it was a racing condition that would sometimes construct a filewatcher when there was physically no file to watch since a new file did not exist on disk yet.

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.