Click here to Skip to main content
15,921,548 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to know if the mobile is downloading or uploading data from internet? Pin
Paul Conrad24-Dec-07 19:42
professionalPaul Conrad24-Dec-07 19:42 
JokeRe: How to know if the mobile is downloading or uploading data from internet? Pin
PIEBALDconsult19-Dec-07 16:58
mvePIEBALDconsult19-Dec-07 16:58 
QuestionApplying event handlers to dynamically generated controls Pin
Spacedmc19-Dec-07 14:14
Spacedmc19-Dec-07 14:14 
GeneralRe: Applying event handlers to dynamically generated controls Pin
J$19-Dec-07 14:46
J$19-Dec-07 14:46 
GeneralRe: Applying event handlers to dynamically generated controls Pin
Spacedmc19-Dec-07 14:59
Spacedmc19-Dec-07 14:59 
GeneralRe: Applying event handlers to dynamically generated controls Pin
Luc Pattyn19-Dec-07 17:35
sitebuilderLuc Pattyn19-Dec-07 17:35 
GeneralRe: Applying event handlers to dynamically generated controls Pin
Anthony Mushrow19-Dec-07 14:49
professionalAnthony Mushrow19-Dec-07 14:49 
GeneralFileSystemWatcher and Threading Pin
#realJSOP19-Dec-07 11:19
professional#realJSOP19-Dec-07 11:19 
I'm writing a service that watches a folder for new files, and kicks off a thread to process the file. The problem is that two threads are being created at the same time (for the same file), and I have no idea why.

Here's the initialization for the watcher object:

string folderToWatch = "C:\\testfolder";
folderWatcher = new FileSystemWatcher(folderToWatch);
folderWatcher.BeginInit();
folderWatcher.EnableRaisingEvents = false;
folderWatcher.Filter = "*.xyz";
folderWatcher.IncludeSubdirectories = false;
folderWatcher.NotifyFilter = NotifyFilters.FileName;
folderWatcher.Created += new FileSystemEventHandler(folderWatcher_Created);
folderWatcher.EndInit();


The folderWatcher is started when the service is started.

Here's the handler for the Created event:

private class ThreadData
{
        public string m_fileName;
	public ErrorHandler m_errorHandler;
	public int m_threadID;
}

private void folderWatcher_Created(object sender, FileSystemEventArgs e)
{
        // create our data transfer object
        ThreadData data = new ThreadData();
	data.m_fileName = e.FullPath;
	data.m_errorHandler = this.m_errorHandler;

        // create a parameterized thread to upload the file.
        Thread thread = new Thread(new ParameterizedThreadStart(UploadFile));
	thread.Name = JustFileName(e.FullPath);
	data.m_threadID = thread.ManagedThreadId;
	thread.Start(data);
}



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


GeneralRe: FileSystemWatcher and Threading Pin
JoeRip19-Dec-07 17:21
JoeRip19-Dec-07 17:21 
GeneralRe: FileSystemWatcher and Threading Pin
JoeRip19-Dec-07 17:32
JoeRip19-Dec-07 17:32 
GeneralRe: FileSystemWatcher and Threading Pin
JoeRip19-Dec-07 17:45
JoeRip19-Dec-07 17:45 
GeneralRe: FileSystemWatcher and Threading Pin
#realJSOP19-Dec-07 23:20
professional#realJSOP19-Dec-07 23:20 
GeneralRe: FileSystemWatcher and Threading Pin
JoeRip20-Dec-07 1:40
JoeRip20-Dec-07 1:40 
GeneralRe: FileSystemWatcher and Threading Pin
#realJSOP20-Dec-07 2:37
professional#realJSOP20-Dec-07 2:37 
GeneralRe: FileSystemWatcher and Threading Pin
JoeRip20-Dec-07 1:42
JoeRip20-Dec-07 1:42 
GeneralProblems with CSV file blowing out memory Pin
LongRange.Shooter19-Dec-07 11:05
LongRange.Shooter19-Dec-07 11:05 
GeneralRe: Problems with CSV file blowing out memory Pin
Ed.Poore19-Dec-07 11:19
Ed.Poore19-Dec-07 11:19 
GeneralRe: Problems with CSV file blowing out memory Pin
LongRange.Shooter19-Dec-07 13:53
LongRange.Shooter19-Dec-07 13:53 
GeneralRe: Problems with CSV file blowing out memory Pin
Skippums19-Dec-07 12:39
Skippums19-Dec-07 12:39 
Generalrandom files with different date Pin
Shani Aulakh19-Dec-07 9:09
Shani Aulakh19-Dec-07 9:09 
GeneralRe: random files with different date Pin
pmarfleet19-Dec-07 9:20
pmarfleet19-Dec-07 9:20 
GeneralRe: random files with different date Pin
Anthony Mushrow19-Dec-07 9:48
professionalAnthony Mushrow19-Dec-07 9:48 
GeneralRe: random files with different date Pin
pmarfleet19-Dec-07 9:58
pmarfleet19-Dec-07 9:58 
GeneralRe: random files with different date Pin
Shani Aulakh19-Dec-07 17:50
Shani Aulakh19-Dec-07 17:50 
GeneralRe: random files with different date Pin
Dave Kreskowiak20-Dec-07 8:57
mveDave Kreskowiak20-Dec-07 8:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.