Board index » Visual Studio » VB6 Multithreading...

VB6 Multithreading...

Visual Studio73
I know, I know.... Don't do it :) Well... Unfortunately I don't have a lot

of choice... ;)



OK, so I'm working on changing some of our existing applications to use a

multithreaded model using the correct method of seperate ActiveX exe's and

NOT that nasty CreateThread API... Tis a daunting task and that's no joke!!



For the most part I've got it working fine.. I instantiate the exe, call the

method I need and the carry on doing other stuff. When my method is done it

sends an event back to my form and Bob's your auntie.. All nice & it doesn't

block my apps GUI at all :)



Now, some of our forms are VERY complex, and contain a lot of controls for

which we have written wrappers to extend their functionality. (Please don't

ask why they're not OCX's... there were reasons at the time! ;) ). What I'd

like to do is rather than setup these controls in my form, which take a

while as some are comboboxes which populate themselves with reference data,

I'd like to set them up in my activex exe, and let that deal with any data

validating etc, leaving my form as just a communications layer between

different ActiveX exe's.



All was working well until I tried to pass an instrinsic control to the

ActiveX exe... It seems I cannot send an object by it's specific type (such

as a TextBox), as these controls are instantiated privately... The only way

is to send as an Object, which means late-binding (yuk)... The end result

required is a responsive GUI that doesn't freeze everytime anything that

takes more than a split second is done, hence the idea of using multiple

threads to do the work...



So, to my question... Is there any way of sending the intrinsic control

rather than a more generic object to an ActiveX exe? I'm not too worried

about cross-process communication overhead, anything's an improvement over

the current sluggish way our app runs, I'd just rather not have the

additional overhead of late binding too, besides, intellisense doesn't work

then...



Any suggestions? (And sorry about the length of the post)...



Thanks



Lorne


-
 

Re:VB6 Multithreading...

I assume you're passing the box 'cause there's more than just Text to set?



If so, Late binding is definitely the safest way to go.



PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error Message

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=kb;en-us;190210&Product=vbb



Intrinsics are safer than ActiveX but they can still cause problems.



--

Ken Halter - MS-MVP-VB - www.vbsight.com">www.vbsight.com

Please keep it in the groups..





"Lorne Smith" <no@spam.here>wrote in message

Quote
I know, I know.... Don't do it :) Well... Unfortunately I don't have a lot

of choice... ;)



OK, so I'm working on changing some of our existing applications to use a

multithreaded model using the correct method of seperate ActiveX exe's and

NOT that nasty CreateThread API... Tis a daunting task and that's no joke!!



For the most part I've got it working fine.. I instantiate the exe, call the

method I need and the carry on doing other stuff. When my method is done it

sends an event back to my form and Bob's your auntie.. All nice & it doesn't

block my apps GUI at all :)



Now, some of our forms are VERY complex, and contain a lot of controls for

which we have written wrappers to extend their functionality. (Please don't

ask why they're not OCX's... there were reasons at the time! ;) ). What I'd

like to do is rather than setup these controls in my form, which take a

while as some are comboboxes which populate themselves with reference data,

I'd like to set them up in my activex exe, and let that deal with any data

validating etc, leaving my form as just a communications layer between

different ActiveX exe's.



All was working well until I tried to pass an instrinsic control to the

ActiveX exe... It seems I cannot send an object by it's specific type (such

as a TextBox), as these controls are instantiated privately... The only way

is to send as an Object, which means late-binding (yuk)... The end result

required is a responsive GUI that doesn't freeze everytime anything that

takes more than a split second is done, hence the idea of using multiple

threads to do the work...



So, to my question... Is there any way of sending the intrinsic control

rather than a more generic object to an ActiveX exe? I'm not too worried

about cross-process communication overhead, anything's an improvement over

the current sluggish way our app runs, I'd just rather not have the

additional overhead of late binding too, besides, intellisense doesn't work

then...



Any suggestions? (And sorry about the length of the post)...



Thanks



Lorne













-

Re:VB6 Multithreading...

Oh well... That's basically the conclusion I'd come to... Still, thanks for

confirming that Ken...



Would be nice if I could persuade my boss to update to .NET... but the

chances of him buying a volume license for 50 developers is slim to

nonexistant! ;-)



Lorne



"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com>wrote in message

Quote
I assume you're passing the box 'cause there's more than just Text to set?



If so, Late binding is definitely the safest way to go.



PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error

Message

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=kb;en-us;190210&Product=vbb



Intrinsics are safer than ActiveX but they can still cause problems.



--

Ken Halter - MS-MVP-VB - www.vbsight.com">www.vbsight.com

Please keep it in the groups..





"Lorne Smith" <no@spam.here>wrote in message

news:eZj$eCX8DHA.1548@tk2msftngp13.phx.gbl...

>I know, I know.... Don't do it :) Well... Unfortunately I don't have a

lot

>of choice... ;)

>

>OK, so I'm working on changing some of our existing applications to use

a

>multithreaded model using the correct method of seperate ActiveX exe's

and

>NOT that nasty CreateThread API... Tis a daunting task and that's no

joke!!

>

>For the most part I've got it working fine.. I instantiate the exe, call

the

>method I need and the carry on doing other stuff. When my method is

done it

>sends an event back to my form and Bob's your auntie.. All nice & it

doesn't

>block my apps GUI at all :)

>

>Now, some of our forms are VERY complex, and contain a lot of controls

for

>which we have written wrappers to extend their functionality. (Please

don't

>ask why they're not OCX's... there were reasons at the time! ;) ). What

I'd

>like to do is rather than setup these controls in my form, which take a

>while as some are comboboxes which populate themselves with reference

data,

>I'd like to set them up in my activex exe, and let that deal with any

data

>validating etc, leaving my form as just a communications layer between

>different ActiveX exe's.

>

>All was working well until I tried to pass an instrinsic control to the

>ActiveX exe... It seems I cannot send an object by it's specific type

(such

>as a TextBox), as these controls are instantiated privately... The only

way

>is to send as an Object, which means late-binding (yuk)... The end

result

>required is a responsive GUI that doesn't freeze everytime anything that

>takes more than a split second is done, hence the idea of using multiple

>threads to do the work...

>

>So, to my question... Is there any way of sending the intrinsic control

>rather than a more generic object to an ActiveX exe? I'm not too

worried

>about cross-process communication overhead, anything's an improvement

over

>the current sluggish way our app runs, I'd just rather not have the

>additional overhead of late binding too, besides, intellisense doesn't

work

>then...

>

>Any suggestions? (And sorry about the length of the post)...

>

>Thanks

>

>Lorne

>

>

>

>









-

Re:VB6 Multithreading...

What about this:



Private Sub subTest(ctrl As Control)

If ctrl.Tag = "txt" Then

'do stuff

ElseIf ctrl.Tag = "cbx" Then

'do stuff

End If

End Sub



It means you'd have to use the Tag property and set it up with some

text. However, you could also use Public Property Let/Get on the

controls to create your own tag, Tag2.



My question is, Is that considered Late-Binding?



--

Jim Carlock

www.microcosmotalk.com/">www.microcosmotalk.com/

Post replies to the newsgroup.





"Lorne Smith" <no@spam.here>wrote in message

Oh well... That's basically the conclusion I'd come to... Still, thanks for

confirming that Ken...



Would be nice if I could persuade my boss to update to .NET... but the

chances of him buying a volume license for 50 developers is slim to

nonexistant! ;-)



Lorne



"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com>wrote in message

Quote
I assume you're passing the box 'cause there's more than just Text to set?



If so, Late binding is definitely the safest way to go.



PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error

Message

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=kb;en-us;190210&Product=vbb



Intrinsics are safer than ActiveX but they can still cause problems.



--

Ken Halter - MS-MVP-VB - www.vbsight.com">www.vbsight.com

Please keep it in the groups..





"Lorne Smith" <no@spam.here>wrote in message

news:eZj$eCX8DHA.1548@tk2msftngp13.phx.gbl...

>I know, I know.... Don't do it :) Well... Unfortunately I don't have a

lot

>of choice... ;)

>

>OK, so I'm working on changing some of our existing applications to use

a

>multithreaded model using the correct method of seperate ActiveX exe's

and

>NOT that nasty CreateThread API... Tis a daunting task and that's no

joke!!

>

>For the most part I've got it working fine.. I instantiate the exe, call

the

>method I need and the carry on doing other stuff. When my method is

done it

>sends an event back to my form and Bob's your auntie.. All nice & it

doesn't

>block my apps GUI at all :)

>

>Now, some of our forms are VERY complex, and contain a lot of controls

for

>which we have written wrappers to extend their functionality. (Please

don't

>ask why they're not OCX's... there were reasons at the time! ;) ). What

I'd

>like to do is rather than setup these controls in my form, which take a

>while as some are comboboxes which populate themselves with reference

data,

>I'd like to set them up in my activex exe, and let that deal with any

data

>validating etc, leaving my form as just a communications layer between

>different ActiveX exe's.

>

>All was working well until I tried to pass an instrinsic control to the

>ActiveX exe... It seems I cannot send an object by it's specific type

(such

>as a TextBox), as these controls are instantiated privately... The only

way

>is to send as an Object, which means late-binding (yuk)... The end

result

>required is a responsive GUI that doesn't freeze everytime anything that

>takes more than a split second is done, hence the idea of using multiple

>threads to do the work...

>

>So, to my question... Is there any way of sending the intrinsic control

>rather than a more generic object to an ActiveX exe? I'm not too

worried

>about cross-process communication overhead, anything's an improvement

over

>the current sluggish way our app runs, I'd just rather not have the

>additional overhead of late binding too, besides, intellisense doesn't

work

>then...

>

>Any suggestions? (And sorry about the length of the post)...

>

>Thanks

>

>Lorne

>

>

>

>











-

Re:VB6 Multithreading...

You cannot send the object as a Control object either... You get the same

error. It seems you can ONLY send it to an ActiveX exe as a generic OBJECT

and then use late binding... You can still check it's type using the

TypeName and TypeOf functions to see what the object is, but you cannot cast

it back to the intrinsic object type and are therefore stuck with late

binding... Such a shame really, but them's the breaks unfortunately... :(



Oh, and I can't use the TAG property as I'm using that in conjunction with a

little control anchoring OCX I wrote a while ago...



I can work with it late bound... I was just hoping to avoid that overhead

(and I didn't really want to lose the intellisense!)... Now I'm going to

have to actually REMEMBER the control methods & properties! hehehe



I dunno... all this grief just to get asynchronous code execution to work...

;>)



Lorne





"Jim Carlock" <anonymous@10.10.com>wrote in message

Quote
What about this:



Private Sub subTest(ctrl As Control)

If ctrl.Tag = "txt" Then

'do stuff

ElseIf ctrl.Tag = "cbx" Then

'do stuff

End If

End Sub



It means you'd have to use the Tag property and set it up with some

text. However, you could also use Public Property Let/Get on the

controls to create your own tag, Tag2.



My question is, Is that considered Late-Binding?



--

Jim Carlock

www.microcosmotalk.com/">www.microcosmotalk.com/

Post replies to the newsgroup.





"Lorne Smith" <no@spam.here>wrote in message

news:e2dFSUj8DHA.1632@TK2MSFTNGP12.phx.gbl...

Oh well... That's basically the conclusion I'd come to... Still, thanks

for

confirming that Ken...



Would be nice if I could persuade my boss to update to .NET... but the

chances of him buying a volume license for 50 developers is slim to

nonexistant! ;-)



Lorne



"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com>wrote in message

news:#$WMu0Z8DHA.1816@TK2MSFTNGP12.phx.gbl...

>I assume you're passing the box 'cause there's more than just Text to

set?

>

>If so, Late binding is definitely the safest way to go.

>

>PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error

Message

>

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=kb;en-us;190210&Product=vbb

>

>Intrinsics are safer than ActiveX but they can still cause problems.

>

>--

>Ken Halter - MS-MVP-VB - www.vbsight.com">www.vbsight.com

>Please keep it in the groups..

>

>

>"Lorne Smith" <no@spam.here>wrote in message

>news:eZj$eCX8DHA.1548@tk2msftngp13.phx.gbl...

>>I know, I know.... Don't do it :) Well... Unfortunately I don't have

a

lot

>>of choice... ;)

>>

>>OK, so I'm working on changing some of our existing applications to

use

a

>>multithreaded model using the correct method of seperate ActiveX exe's

and

>>NOT that nasty CreateThread API... Tis a daunting task and that's no

joke!!

>>

>>For the most part I've got it working fine.. I instantiate the exe,

call

the

>>method I need and the carry on doing other stuff. When my method is

done it

>>sends an event back to my form and Bob's your auntie.. All nice & it

doesn't

>>block my apps GUI at all :)

>>

>>Now, some of our forms are VERY complex, and contain a lot of controls

for

>>which we have written wrappers to extend their functionality. (Please

don't

>>ask why they're not OCX's... there were reasons at the time! ;) ).

What

I'd

>>like to do is rather than setup these controls in my form, which take

a

>>while as some are comboboxes which populate themselves with reference

data,

>>I'd like to set them up in my activex exe, and let that deal with any

data

>>validating etc, leaving my form as just a communications layer between

>>different ActiveX exe's.

>>

>>All was working well until I tried to pass an instrinsic control to

the

>>ActiveX exe... It seems I cannot send an object by it's specific type

(such

>>as a TextBox), as these controls are instantiated privately... The

only

way

>>is to send as an Object, which means late-binding (yuk)... The end

result

>>required is a responsive GUI that doesn't freeze everytime anything

that

>>takes more than a split second is done, hence the idea of using

multiple

>>threads to do the work...

>>

>>So, to my question... Is there any way of sending the intrinsic

control

>>rather than a more generic object to an ActiveX exe? I'm not too

worried

>>about cross-process communication overhead, anything's an improvement

over

>>the current sluggish way our app runs, I'd just rather not have the

>>additional overhead of late binding too, besides, intellisense doesn't

work

>>then...

>>

>>Any suggestions? (And sorry about the length of the post)...

>>

>>Thanks

>>

>>Lorne

>>

>>

>>

>>

>

>











-

Re:VB6 Multithreading...

Then I have another idea, put the control on a blank form, and pass the

form?



Private Sub subGoofy(frm As Form)



Is it a visible control? If it's a visible control the form thing might

not work, in which case, you might be able to put it into a picturebox

or an imagebox or a frame?



--

Jim Carlock

www.microcosmotalk.com/">www.microcosmotalk.com/

Post replies to the newsgroup.





"Lorne Smith" <no@spam.here>wrote in message

You cannot send the object as a Control object either... You get the same

error. It seems you can ONLY send it to an ActiveX exe as a generic OBJECT

and then use late binding... You can still check it's type using the

TypeName and TypeOf functions to see what the object is, but you cannot cast

it back to the intrinsic object type and are therefore stuck with late

binding... Such a shame really, but them's the breaks unfortunately... :(



Oh, and I can't use the TAG property as I'm using that in conjunction with a

little control anchoring OCX I wrote a while ago...



I can work with it late bound... I was just hoping to avoid that overhead

(and I didn't really want to lose the intellisense!)... Now I'm going to

have to actually REMEMBER the control methods & properties! hehehe



I dunno... all this grief just to get asynchronous code execution to work...

;>)



Lorne





"Jim Carlock" <anonymous@10.10.com>wrote in message

Quote
What about this:



Private Sub subTest(ctrl As Control)

If ctrl.Tag = "txt" Then

'do stuff

ElseIf ctrl.Tag = "cbx" Then

'do stuff

End If

End Sub



It means you'd have to use the Tag property and set it up with some

text. However, you could also use Public Property Let/Get on the

controls to create your own tag, Tag2.



My question is, Is that considered Late-Binding?



--

Jim Carlock

www.microcosmotalk.com/">www.microcosmotalk.com/

Post replies to the newsgroup.





"Lorne Smith" <no@spam.here>wrote in message

news:e2dFSUj8DHA.1632@TK2MSFTNGP12.phx.gbl...

Oh well... That's basically the conclusion I'd come to... Still, thanks

for

confirming that Ken...



Would be nice if I could persuade my boss to update to .NET... but the

chances of him buying a volume license for 50 developers is slim to

nonexistant! ;-)



Lorne



"Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com>wrote in message

news:#$WMu0Z8DHA.1816@TK2MSFTNGP12.phx.gbl...

>I assume you're passing the box 'cause there's more than just Text to

set?

>

>If so, Late binding is definitely the safest way to go.

>

>PRB: Passing ActiveX Control to Component Gives "Type Mismatch" Error

Message

>

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=kb;en-us;190210&Product=vbb

>

>Intrinsics are safer than ActiveX but they can still cause problems.

>

>--

>Ken Halter - MS-MVP-VB - www.vbsight.com">www.vbsight.com

>Please keep it in the groups..

>

>

>"Lorne Smith" <no@spam.here>wrote in message

>news:eZj$eCX8DHA.1548@tk2msftngp13.phx.gbl...

>>I know, I know.... Don't do it :) Well... Unfortunately I don't have

a

lot

>>of choice... ;)

>>

>>OK, so I'm working on changing some of our existing applications to

use

a

>>multithreaded model using the correct method of seperate ActiveX exe's

and

>>NOT that nasty CreateThread API... Tis a daunting task and that's no

joke!!

>>

>>For the most part I've got it working fine.. I instantiate the exe,

call

the

>>method I need and the carry on doing other stuff. When my method is

done it

>>sends an event back to my form and Bob's your auntie.. All nice & it

doesn't

>>block my apps GUI at all :)

>>

>>Now, some of our forms are VERY complex, and contain a lot of controls

for

>>which we have written wrappers to extend their functionality. (Please

don't

>>ask why they're not OCX's... there were reasons at the time! ;) ).

What

I'd

>>like to do is rather than setup these controls in my form, which take

a

>>while as some are comboboxes which populate themselves with reference

data,

>>I'd like to set them up in my activex exe, and let that deal with any

data

>>validating etc, leaving my form as just a communications layer between

>>different ActiveX exe's.

>>

>>All was working well until I tried to pass an instrinsic control to

the

>>ActiveX exe... It seems I cannot send an object by it's specific type

(such

>>as a TextBox), as these controls are instantiated privately... The

only

way

>>is to send as an Object, which means late-binding (yuk)... The end

result

>>required is a responsive GUI that doesn't freeze everytime anything

that

>>takes more than a split second is done, hence the idea of using

multiple

>>threads to do the work...

>>

>>So, to my question... Is there any way of sending the intrinsic

control

>>rather than a more generic object to an ActiveX exe? I'm not too

worried

>>about cross-process communication overhead, anything's an improvement

over

>>the current sluggish way our app runs, I'd just rather not have the

>>additional overhead of late binding too, besides, intellisense doesn't

work

>>then...

>>

>>Any suggestions? (And sorry about the length of the post)...

>>

>>Thanks

>>

>>Lorne

>>

>>

>>

>>

>

>













-