Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 13 total |
EWB Module - CoInitialize has not been called |
Thu, Apr 9 2015 4:00 AM | Permanent Link |
Petter Topp | I use TADOConnection and TADOQuery to handle login on the server side in my EWB Module.
When the module receives a request (getting created?), I get the message "CoInitialize has not been called" It seems that this is related to threading issues - can someone enlighten me on how to solve this? Br Petter |
Thu, Apr 9 2015 4:34 AM | Permanent Link |
Matthew Jones | Petter Topp wrote:
> I use TADOConnection and TADOQuery to handle login on the server side > in my EWB Module. When the module receives a request (getting > created?), I get the message "CoInitialize has not been called" > > It seems that this is related to threading issues - can someone > enlighten me on how to solve this? In the multi-threaded code I have, where I've needed to access COM objects, I have the initialization code of the thread call CoInitialize(nil); and in closing down the thread, it calls CoUninitialize(); You'd probably have to be careful to not break any COM in the server itself, but given it isn't initialised, it is probably safe. -- Matthew Jones |
Thu, Apr 9 2015 5:10 AM | Permanent Link |
Petter Topp | Hi Matthew.
As for the moment I don't see the need for multi threading - So the place to do this would be in the EWBModuleExecute event? "Matthew Jones" wrote: Petter Topp wrote: > I use TADOConnection and TADOQuery to handle login on the server side > in my EWB Module. When the module receives a request (getting > created?), I get the message "CoInitialize has not been called" > > It seems that this is related to threading issues - can someone > enlighten me on how to solve this? In the multi-threaded code I have, where I've needed to access COM objects, I have the initialization code of the thread call CoInitialize(nil); and in closing down the thread, it calls CoUninitialize(); You'd probably have to be careful to not break any COM in the server itself, but given it isn't initialised, it is probably safe. -- Matthew Jones |
Thu, Apr 9 2015 5:42 AM | Permanent Link |
Matthew Jones | Petter Topp wrote:
> As for the moment I don't see the need for multi threading - So the > place to do this would be in the EWBModuleExecute event? The service you are writing a module will be multi-threaded, so it is inherently something to consider. However I now walk off the deep end as I've not written an EWB module. A quick scan of the documentation shows that it is about "modules", which means that the server will own the module which is all about the data/connection etc, but there is nothing on threads. A typical server will have a thread pool, and any one of those could call your code at any time. Without further information, I would have a routine which is called "CheckOLEInit" and put this code in: threadvar g_bInitialisedCOM = False; procedure CheckOLEInit; begin if not g_bInitialisedCOM then begin CoInitialize(nil); g_bInitialisedCOM := True; end; end; The threadvar is a "global" but on a per thread basis, so it won't be set for each thread that you get called by. Thus each thread would have the initialisation done once (or initialization for the US language!). I'd also then ignore the UnInitialize, and you are going to keep it alive until the server shuts down, and without explicit thread control, it would be hard. I'd prefer to have Tim respond on how sensible this is, or if there is a better way. IIRC there is a DLL attachment call for each new thread, but that probably won't apply when the thread already exists. The ideal, perhaps, would be for the server to do this call for you, just in case. There's no real harm. -- Matthew Jones |
Thu, Apr 9 2015 10:19 AM | Permanent Link |
Matthew Jones | Matthew Jones wrote:
> The service you are writing a module will be multi-threaded Should of course be: The service you are writing a module *for* will be multi-threaded That will make better sense! -- Matthew Jones |
Thu, Apr 9 2015 12:27 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Petter,
<< I use TADOConnection and TADOQuery to handle login on the server side in my EWB Module. When the module receives a request (getting created?), I get the message "CoInitialize has not been called" It seems that this is related to threading issues - can someone enlighten me on how to solve this? >> Yes, you want to make sure to call CoInitialize in the initialization of the project .dpr: begin <<<<<<<<<<<<<<<<<<<<<<<<< Here !!!! Application.Initialize; Application.CreateForm(TExampleDataSetModule, ExampleDataSetModule); Application.Run; end. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Fri, Apr 10 2015 2:08 AM | Permanent Link |
Petter Topp | Hi Tim.
I have added CoInitialize(nil) in the initialization of the project, but I still get "CoInitialize has not been called" Petter "Tim Young [Elevate Software]" wrote: Petter, << I use TADOConnection and TADOQuery to handle login on the server side in my EWB Module. When the module receives a request (getting created?), I get the message "CoInitialize has not been called" It seems that this is related to threading issues - can someone enlighten me on how to solve this? >> Yes, you want to make sure to call CoInitialize in the initialization of the project .dpr: begin <<<<<<<<<<<<<<<<<<<<<<<<< Here !!!! Application.Initialize; Application.CreateForm(TExampleDataSetModule, ExampleDataSetModule); Application.Run; end. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Fri, Apr 10 2015 4:15 AM | Permanent Link |
Matthew Jones | Tim Young [Elevate Software] wrote:
> Yes, you want to make sure to call CoInitialize in the initialization > of the project .dpr: Tim, It is needed in each thread that may make a COM call. Once at the start is not enough. -- Matthew Jones |
Fri, Apr 10 2015 4:27 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< It is needed in each thread that may make a COM call. Once at the start is not enough. >> Oops, sorry, was thinking of the database engine initialization. To initialize for each thread, just call CoInitialize in the OnCreate for the EWB Web Server module. Tim Young Elevate Software www.elevatesoft.com |
Tue, Sep 1 2015 6:01 AM | Permanent Link |
Petter Topp | "Tim Young [Elevate Software]" wrote:
Matthew, << It is needed in each thread that may make a COM call. Once at the start is not enough. >> Oops, sorry, was thinking of the database engine initialization. To initialize for each thread, just call CoInitialize in the OnCreate for the EWB Web Server module. Tim Young Elevate Software www.elevatesoft.com Hi Tim. Calling CoInitialize in the OnCreate for the EWB server module partially helped. Now the CoInitialize message only the first time the EWBModuleExecute is called. Any Ideas as to how I can solve this? Petter |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Wednesday, September 18, 2024 at 05:13 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |