C# Threading Issue

P

PhilBray

Hello,

I am currently having an issue with the FileSystemWatcher class for an
application I am developing. I use the FileSystemWatcher class to
identify a change in a directory (i.e. a file has been added) and once
this event is captured then I make a call to another class which
implements calls to a camera SDK.

The issue I am having is that when using FileSystemWatcher to create a
new version of my class and start making calls to an asynchronous
camera capture() method, the call is made and then when check
has_captured flag, this is always immediately set to complete although
now picture has been taken. When I call to this class however from a
basic console application the call to the capture() method is made and
then the has_captured flag is only set once a picture has been taken
as I would expect.

I have therefore started to think it may have something to do with the
event thread that is fired when using the FileSystemWatcher class.

Can anybody provide any input to this issue.

Many thanks in advance,

Phil
 
B

Bobbo

I am currently having an issue with the FileSystemWatcher class

It may or may not be related to your problem, but if you search this
newsgroup for recent posts containing "FileSystemWatcher", somebody
else had a similar problem to you where the file creation event was
firing before the creating application had finished writing it.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

| Hello,
|
| I am currently having an issue with the FileSystemWatcher class for an
| application I am developing. I use the FileSystemWatcher class to
| identify a change in a directory (i.e. a file has been added) and once
| this event is captured then I make a call to another class which
| implements calls to a camera SDK.
|
| The issue I am having is that when using FileSystemWatcher to create a
| new version of my class and start making calls to an asynchronous
| camera capture() method, the call is made and then when check
| has_captured flag, this is always immediately set to complete although
| now picture has been taken. When I call to this class however from a
| basic console application the call to the capture() method is made and
| then the has_captured flag is only set once a picture has been taken
| as I would expect.
|
| I have therefore started to think it may have something to do with the
| event thread that is fired when using the FileSystemWatcher class.

It's possible, but IMO this depend of the camera you are using and how you
should comunicate with it. Also note that sometimes the FileSystemWatcher
fires more than one event for the same action from the file. I would also
check for this.

How you communicate with the camera?
 
P

PhilBray

It may or may not be related to your problem, but if you search this
newsgroup for recent posts containing "FileSystemWatcher", somebody
else had a similar problem to you where the file creation event was
firing before the creating application had finished writing it.

Hi Bobbo,

I resolved the issue but it was related to the build path I was using
when using the FileSystemWatcher application. For some reason I was
not getting all the required SDK DLL's brought into my build directory
at runtime.

All is now good but thanks for the fast response.

Phil
 
P

PhilBray

Hi,


| Hello,
|
| I am currently having an issue with the FileSystemWatcher class for an
| application I am developing. I use the FileSystemWatcher class to
| identify a change in a directory (i.e. a file has been added) and once
| this event is captured then I make a call to another class which
| implements calls to a camera SDK.
|
| The issue I am having is that when using FileSystemWatcher to create a
| new version of my class and start making calls to an asynchronous
| camera capture() method, the call is made and then when check
| has_captured flag, this is always immediately set to complete although
| now picture has been taken. When I call to this class however from a
| basic console application the call to the capture() method is made and
| then the has_captured flag is only set once a picture has been taken
| as I would expect.
|
| I have therefore started to think it may have something to do with the
| event thread that is fired when using the FileSystemWatcher class.

It's possible, but IMO this depend of the camera you are using and how you
should comunicate with it. Also note that sometimes the FileSystemWatcher
fires more than one event for the same action from the file. I would also
check for this.

How you communicate with the camera?

Hi,

I resolved the issue but it was related to the build path I was using.

Thanks for the response.

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top