|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Object Type Conversion ErrorThe below code keeps giving me the error: Conversion from type 'Object()' to type 'Integer' is not valid. Do I need to do some casting or somethign? All I'm doing is passing an object which contains a structure, Dictionary(type Integer, string) and a system.directoryservices.searchresultcollection. Dim ControlThreadVals As Object = New Object() {svrInfo, dcDict, svrResults} Try '******Here's where I get the error: ********************* controllerThread = New System.Threading.Thread(AddressOf ControlThread, ControlThreadVals) '******************************************************** controllerThread.IsBackground = True controllerThread.Start() While controllerThread.IsAlive Application.DoEvents() End While Catch ex As Exception Dim strErr As String = ex.Message Debugger.Break() End Try Ooops, sorry! The while loop is actually outside the try catch block,
as below. Dim ControlThreadVals As Object = New Object() {svrInfo, dcDict, svrResults} Try '******Here's where I get the error: ********************* controllerThread = New System.Threading.Thread(AddressOf ControlThread, ControlThreadVals) '******************************************************** controllerThread.IsBackground = True controllerThread.Start() Catch ex As Exception Dim strErr As String = ex.Message Debugger.Break() End Try While controllerThread.IsAlive Application.DoEvents() End While Bmack500 wrote:
> Dim ControlThreadVals As Object = New Object() {svrInfo, Well, according to the docs, none of the constructors for the Thread> dcDict, svrResults} > Try > '******Here's where I get the error: ********************* > controllerThread = New System.Threading.Thread(AddressOf > ControlThread, ControlThreadVals) > '******************************************************** class takes an object array as a parameter. Since ControlThreadVals is an object array and not an integer, it produces the exception you are seeing. Oh, I see. I had a similiar section in my code, but I had it wrapped in
a class first. Thanks! Chris Dunaway wrote: Show quoteHide quote > Bmack500 wrote: > > > Dim ControlThreadVals As Object = New Object() {svrInfo, > > dcDict, svrResults} > > Try > > '******Here's where I get the error: ********************* > > controllerThread = New System.Threading.Thread(AddressOf > > ControlThread, ControlThreadVals) > > '******************************************************** > > Well, according to the docs, none of the constructors for the Thread > class takes an object array as a parameter. Since ControlThreadVals is > an object array and not an integer, it produces the exception you are > seeing. |
|||||||||||||||||||||||