Skip to content

FileSystemWatcher with winforms Form as SynchronizingObject: event handlers not called on forms thread #52644

Closed

Description

@msneijders

Description

Using FileSystemWatcher on a Winforms Form, setting SynchronizeObject to this form and adding a Changed event handler. This handler is executed on a different thread (worker thread) than this Form was created on (main thread). According to docs it should execute on the main thread?

Small test solution:

WinFormsApp_FileSystemWatcher.zip

Configuration

.NET 5.0.6

Regression?

It is at least a regression coming from .NET Framework 4.7.1, but I haven't tested a previous .NET Core version.

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on May 12, 2021
  2. Balkoth commented on May 18, 2021

    @Balkoth

    I can confirm this, as i just came across this issue and wanted to write a bug report myself. Even if SynchronizingObject is set to a Control on the UI-Thread and InvokeRequired is true, the event handlers are called from a different thread.

  3. thomsj commented on May 23, 2021

    @thomsj
    Contributor

    I also noticed this, a couple of months ago. I've just committed my fix.

  4. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on May 23, 2021
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 16, 2021
  6. added this to the 6.0.0 milestone on Jun 16, 2021
  7. added a commit that references this issue on Aug 13, 2021
    d8706a1
  8. added a commit that references this issue on Aug 13, 2021
    5817dc8
  9. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 13, 2021
  10. ghost locked as resolved and limited conversation to collaborators on Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions