K
KC
Hey,
I'm trying to implement a cancel button in my app (this is after the bulk of
the program has been built). To do this I, of course, need to use a thread
to run the time consuming method while the UI continues on it's merry way. I
created a basic thread just as an initial test and I half expected it to
crash - and it did. My problem is I don't understand why and that's making
it hard to debug.
The whole thing crashes (I get the old 'object reference not set to an
instance of an object' error) after the method completes. The method that
I'm threading pulls data off a website, crunches some numbers, puts the
results in a datatable that is part of a dataset that is bound to a
datagrid.
Is it because I'm trying to update a control (which was created in the UI
thread)? That's the blank spot for me. I don't know what's suppose to happen
when my method/thread finishes.
I'm reading
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet09272002.asp
about background processes but my methods and functions are built and use a
lot of info from the UI. Trying to separate them into a 'worker' class looks
problematic. Ideas? Links to simpler way of implementing a cancel button?
I'm trying to implement a cancel button in my app (this is after the bulk of
the program has been built). To do this I, of course, need to use a thread
to run the time consuming method while the UI continues on it's merry way. I
created a basic thread just as an initial test and I half expected it to
crash - and it did. My problem is I don't understand why and that's making
it hard to debug.
The whole thing crashes (I get the old 'object reference not set to an
instance of an object' error) after the method completes. The method that
I'm threading pulls data off a website, crunches some numbers, puts the
results in a datatable that is part of a dataset that is bound to a
datagrid.
Is it because I'm trying to update a control (which was created in the UI
thread)? That's the blank spot for me. I don't know what's suppose to happen
when my method/thread finishes.
I'm reading
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet09272002.asp
about background processes but my methods and functions are built and use a
lot of info from the UI. Trying to separate them into a 'worker' class looks
problematic. Ideas? Links to simpler way of implementing a cancel button?