W
whiggins
Hello
I am writing a VB.net windows form that monitors files bing dropped in to a
directory and then parsing the files out and inserting the contents in to a
SQL database. I have a class that is launched off on it's own thread that
has a callback to the main form to update a listbox that contains the files
that are dropped into the directory. I also have a timer the is set to
elapse every 5 seconds or so. In the timer elapsed sub I want to launch a
thread of class INVIThread to parse the files and insert the data. I would
set up an array for class but it has a withevents declaration. I have add
the code that is in the sub below.
I have set up an array of threads and in the sub I increment the threads on
every call to the sub, but on the second go through I get the error:
"Delegate to an instance method cannot have null 'this'."
Any help would be greatly appreciated.
t(Threadcount) = New Thread(AddressOf INVIThread.StartInsert) error line
INVIThread = New InventoryInsert.Inserter
Dim Filename As String = ""
Filename = lbFiles.Items.Item(0).ToString()
INVIThread.FileName = Filename
INVIThread.FilePath = "D:\inventory\"
t(Threadcount).IsBackground = True
t(Threadcount).Name = Mid(Filename, 1, Filename.Length - 4)
t(Threadcount).Start()
Threadcount += 1
I am writing a VB.net windows form that monitors files bing dropped in to a
directory and then parsing the files out and inserting the contents in to a
SQL database. I have a class that is launched off on it's own thread that
has a callback to the main form to update a listbox that contains the files
that are dropped into the directory. I also have a timer the is set to
elapse every 5 seconds or so. In the timer elapsed sub I want to launch a
thread of class INVIThread to parse the files and insert the data. I would
set up an array for class but it has a withevents declaration. I have add
the code that is in the sub below.
I have set up an array of threads and in the sub I increment the threads on
every call to the sub, but on the second go through I get the error:
"Delegate to an instance method cannot have null 'this'."
Any help would be greatly appreciated.
t(Threadcount) = New Thread(AddressOf INVIThread.StartInsert) error line
INVIThread = New InventoryInsert.Inserter
Dim Filename As String = ""
Filename = lbFiles.Items.Item(0).ToString()
INVIThread.FileName = Filename
INVIThread.FilePath = "D:\inventory\"
t(Threadcount).IsBackground = True
t(Threadcount).Name = Mid(Filename, 1, Filename.Length - 4)
t(Threadcount).Start()
Threadcount += 1