COM multithreading fun.

Status
Not open for further replies.

Liam

Ars Scholae Palatinae
618
I'm writing a multithreaded Win32 service for work that needs to call some COM objects. Basically what needs to happen is the main service thread sleeps until a timer object goes off, or it receives a service control message, including an external trigger. If the timer goes off or it receives this trigger, it needs to spring into action, which involves querying a database to find some assignments to run.

I'll interrupt the technical description for a moment to explain the point of this application. We're designing a web-based system that will serve binary files from a database (primarily PDF and Excel renderings of financial reports done by Cognos Impromptu). There's a web portal that the Finance people can go to to submit their reports to be run and converted to PDF and Excel, and another portal for the Execs to go to to view their reports. The service is supposed to query the DB to find which reports have been submitted, spawn the appropriate renderer (at this point, only Impromptu), generate the ouput file, and stick it back in the DB as a BLOB, to be pulled out and served by the Executive web portal.

Running a report through Impromptu involves hammering a DB halfway across the country across a narrow pipe (~256Kbps or so), and some of the reports take an awfully long time to run. Some of them take so long because they're spinning the DB so much, and some take so long because they're spewing so much data back through the pipe, but mostly the former. We'd like to run multiple reports at the same time, so assuming the pipe isn't saturated, the DB will be able to finish the shorter ones first, and our turnaround time will *appear* better to the Finance people (yes, the longer ones will just take longer to run, but there will be more "instant gratification" for the shorter ones).

Back to the main thread. So it hits our local DB to get a list of pending reports, and forks off one thread for each of them, so that it can go back to sleep like a good dispatcher (it's responsible for handling service stop requests, among other things, so it needs to finish its job quickly). Each of these worker threads hits the local DB some more to find pertinent information about the report (filenames, and so on), spawns an instance of Impromptu to run the report and generate some output files, and inserts these files into the local DB.

All local DB accesses are done through ADO (I couldn't find a good way to insert BLOBs in anything else), so the main thread needs COM initialized for that, and so do each of the worker threads. Of course, each thread has to spawn Impromptu (out of process, BTW), so it needs COM for that, too. No COM objects are passed between threads. Originally I passed a single ADO DB connection around to each thread, but I figured that was a Bad Idea, so I had each thread make a copy of it, so as to open its own connection.

When there is only one pending report in the DB, everything seems to work fine. When two reports are there, the two instances of Impromptu seem to step on each other. One of them may finish properly, but they'll eventually hang the service.

My question basically boils down to "How do I ensure that COM is using the correct threading model?" I'm calling CoInitialize(NULL) once in each independent thread, and no COM objects are being passed between threads. Should I initialize COM once at the beginning in some different thread model, or once for each thread in some different model, or what?

Ask questions if something isn't clear.

Liam
 

ironLotus

Ars Scholae Palatinae
1,479
From the fine print located in the Forum Rules at the bottom of the reply page:
Changes: Messages can be edited by their author. Messages can be deleted by their author. Changes must be made within 30 minutes of posting.
You can only edit your post for 30 minutes after you submit it. Otherwise you change history and we all know how bad that can be (e.g. Superman saving Lois Lane from the earthquake, Michael J. Fox's mom falling in love with him in Back To The Future, Prepetual "How I did on CS last night" Thread in the gaming forum)
 

Liam

Ars Scholae Palatinae
618
Well, fortunately no objects are being passed between threads. Once a worker thread is created (with _beginthreadex()), it's completely autonomous until it dies. The main thread is using MsgWaitForMultipleObjects() to block on the worker threads' deaths and incoming messages in its message queue, so it will wake up when a worker thread dies and perform some cleanup. Does this mean I'm free from marshalling COM pointers and synchronizing access to objects?

Basic Windows multithreading question: naturally, since these worker threads are all performing the same action (rendering a document), they all call basically the same functions. Are local variables thread-safe? It was my understanding that I'd only have to use __declspec(thread) on static local variables. What about the standard library objects? I'm passing around vector<>s inside each thread; will each thread own its own objects?

Liam
 
Liam,

Local function variables are always thread safe as they are allocated on the stack, though this isn't true for global variables. You are correct in using the __declspec(thread) modifier to ensure that globals and static variables are allocated per thread using Windows Thread Local Storage (Tls).

The Microsoft C Run Time library ships with a multi-threaded library LIBCMT.LIB. Make sure you're linking with it. As for STL, it should run fine in a multi-threaded environment.

With regards to calling CoInitlize(), you should call it once per worker thread that you create. By defalut this will flag the thread as Single Threaded Apartment thread model (STA), which should be fine. If you try to access other objects using a different threading model COM will marshall calls as needed. Of course my in-depth knowledge of COM threading-models is getting stale so do more research. I recommend codeguru.com or the Microsoft Knowledge base.

Good Luck!
 

Liam

Ars Scholae Palatinae
618
I switched all my CoInitialize(NULL)s to CoInitializeEx(NULL, COINIT_MULTITHREADED)s, but that didn't seem to help much, so I'll put them back. I am, however, making sure that each thread makes one of these calls before doing any COM work, and calling CoUninitialze() before returning.

Task manager shows two instances of ImpAdmin.exe being spawned, which corresponds with my two threads each spawning an Impromptu object. It seems that the first thread to finish its work with the Impromptu application is working properly; when it releases its Impromptu object, this seems to freeze both copies of ImpAdmin.exe. The first thread terminates properly, except for leaving the orphaned Impromptu object, but the second thread blocks forever waiting for its copy of Impromptu to finish running its report.

The odd thing is that everything performs as expected when I step through it with the debugger; both threads exit properly, and clean up their ImpAdmin.exes at the appropriate time. I have noticed that when I am stepping through with the debugger, the COM subsystem seems to be synchronizing the instantiations. I'll choose to step over the instantiation in the first thread that gets there, but nothing will happen until I step over the instantiation in the second thread. Then task manager shows one ImpAdmin.exe being spawned, and when this has completed, the second one begins loading immediately, without ever returning control to the debugger. I'll step through a few more lines, and at some point, the debugger will lose control of both threads, and they'll just run to their (successful) completion, as if I had stopped stepping and just let it run.

It's nice to know that I made a correct assumption about my local variables!

Thanks for the links, I'll check them out.

Edit: yes, I'm linking with the multithreaded C runtime. All builds at this point are debug, so even when I run the program and let it crash, that's the debug build. I haven't tried release, but I realize that that's a different runtime, and needs to be set to multithreaded too.
 

Liam

Ars Scholae Palatinae
618
This particular EXE is capable of having only one document open at a time, so multiple documents require multiple instances. There is a commandline switch that will instruct Impromptu to allow or disallow multiple instance; I've set it to allow. An analog would be something like Media Player; it can only have one document open at a time, so to actually *play* two movies at the same time, you'd have to set it to run multiple instances (which is got to in the options somewhere).

Could it be that Impromptu just doesn't behave well as an out-of-proc server?

It really seems as though the first thread Release()ing its object and CoUninitialize()ing its apartment is locking up COM for both threads, or something along those lines.

Nonhelpful (and fortunately joking) suggestion from my boss:
"Well, we'll just have you sit there with the debugger attached to it whenever we need to run it."

Thanks for the inputs so far, guys. I've had a look at some sites (codeguru and MSDN) without turning up much. Everybody wants to talk about multithreading issues when writing COM _servers_, so apparently what I'm doing is supposed to be a piece of cake.

Liam
 

Liam

Ars Scholae Palatinae
618
I shouldn't *have* to do this, right? You're suggesting basically that I serialize all my COM calls, even though they're to different objects? That may well be why the program seems to work alright in the debugger; I'm effectively serializing the calls.

If this works, will there be *any* performance gain (on our multi-processor server, by exploiting DB concurrancy, etc.) over simply processing one document at a time? I was doing this in an earlier version of the program, and it sure was a helluva lot simpler, but then I got this rabid brainstorm to try and multi-thread the whole lot.

Thanks
Liam
 

Liam

Ars Scholae Palatinae
618
Okay, I think I've narrowed down what's happening. As I mentioned before, Cognos Impromptu (the COM server I'm having problems with) is only capable of having one document open at a time, so in order to render multiple documents simultaneously, multiple copies of the exe have to be instantiated. Apparently, each exe is NOT bound to the COM object it was created through. What seems to be happening is that if my program creates 8 Impromptu objects, 8 copies of ImpAdmin.exe will be run, but COM requests from ALL 8 THREADS will go to the first one, and the others will sit idle. This results in an eventual lockup, because when a request from another thread tries to access this first object, a dialog box will be displayed informing the user that the object is busy. Unfortuanately, the service needs to be run under a domain account, and desktop interaction can only be enabled for services running under the local system account. So any other thread trying to access this object than the one that created it ends up blocking waiting for the user to click a dialog they can't see.

Is there a way to modify this behaviour? When I receive a COM smart pointer to a newly created object, I expect my calls through that pointer to go to THAT object, but that seems not to be what's happening; it's almost as if the COM subsystem is grabbing ahold of the method calls and piping them into the same object, which will NOT work with this application.
 

Liam

Ars Scholae Palatinae
618
Elaborate, please? My app has n threads, and my understanding (maybe "guess," or "intent" would be a better word?!) is that each of these threads will "own" its own copy of the out-of-proc .exe. Each thread blocks while waiting for its personal object to finish a request, which is fine. But on an m-way SMP environment, I'd like to have m of these threads blocking at the same time. Will this not happen they way I'm dreaming?

True, the app doesn't support multithreading. That's why I'm instantiating n apps, rather than assuming one app will handle all n threads' worth of requests.

I seem to have fixed the problem in a console test app (got 8 of the little buggers going at once, I did), but it bombs in the service. :( Now TWO reports get run before the whole kit locks up.
 

TheJet

Ars Praefectus
4,598
Subscriptor++
With an OOP COM server, you are at the mercy of the creator of that server. If they did not setup the thing to allow for multiple copies of the application running at once, then you are SOL, regardless of how many different threads you've created. If this was an IP COM server, then you'd actually get separate copies of the DLL in your own memory space to work with, and multiple threads should help you implicitly.

It's a game of "least common denominator". If you are running x COM servers which use each other, and any one of them doesn't know how, or is incapable of, running in a multithreaded environment, you're done.

Here's my understanding of the COM infrastructure (as it relates to OOP servers), please someone else jump in to correct any of my mistakes/misinterpretations:

1) Application x requests an OOP COM object

2) OS looks for an existing running app which provides the necessary IClassFactory interface (?and supports the current threading model?)

3) If none is found, it queries the registry for the information on how to start the OOP server. It then launches that application, which should (at startup) register an IClassFactory interface for all the COM interfaces it supports.

4) OS uses the registered ClassFactory and creates a cross-process proxy for the object and hands it to the calling application. All calls to the object are marshalled through the proxy to the OOP server, and responses are marshalled back.

If say the object is setup to support free threading, and you're running in an MTA, then you may get the behavior you're seeing (although I can't explain the multiple exe instances). This would be especially true if the object is using some sort of thread synchronization protection against the method you're calling. The first thread in would get control of the object until it's done, basically serializing all access to that method on the object. What you may be able to do is just change the threading model in the registry to be an apartment threaded model ==> ThreadingModel: REG_SZ: "Apartment".

TheJet

DISCLAIMER: I'm no expert, but I've had to deal with this type of stuff when trying to troubleshoot problems with VB6/ATL/3rd party COM components before, and it almost always ended up being some incompatibility between the threading models used. At some point, I want to go through and get my entire understanding of the COM stuff written down so I can correct/expand it a bit, COM can be quite confusing and convoluted. :(
 

Liam

Ars Scholae Palatinae
618
Here might be some relavent background information about how Impromptu does its thang: Impromptu reports are designed with reference to a catalog file. The catalog is created by someone (my boss) who is a programmer, using Impromptu Administrator. The catalog contains database connection info, and a subset of the DB's tables are included and joined together in various ways, so as to simplify the view of the data. Reports are created with Impromptu User (or Admin, but Admin is more expensive, so we don't bother licensing it for most of the finance folks), and are bound to a catalog. Data fields can be dragged out of the catalog, and filters applied with GUI menus and things, and Impromptu generates the SQL behind the scenes. The report can also use prompts, which basically define variables that can then be used in calculations, filters, etc. The user is prompted for the value of these variables when the database is queried. Impromptu also formats the displayed results very nicely and flexibly, and can export the rendered form as a PDF document, which is very true to the original. Standard "business intelligence reporting tool," whatever that means.

Impromptu User (and Impromptu Admin, for that matter) is capable of having only one catalog and one report open at any given time. If I run multiple instances (not through automation), however, I can have multiple reports open at the same time with no problem; one report/catalog pair per instance. Each instance corresponds also to an occurrence of "ImpUser.exe" in task manager. This brings us to the automation part. The relevant methods are (copied from the .tlh file generated by my #import statement; I added the class names so you know what's with what, and stuck some comments in there):

code:<HR>
Code:
VARIANT_BOOL IAppAuto::Visible (
        const _variant_t & bShowWindow );<P>VARIANT_BOOL IAppAuto::OpenCatalog (
        _bstr_t szCatalogFileName,
        const _variant_t & szUserClass,  // always "User"
        const _variant_t & szUserPassword, // always vtMissing, as the User class does not have a password
        const _variant_t & szDBUserID,  // if bConnectDB is false, this is not needed
        const _variant_t & szDBPassword,  // ditto
        const _variant_t & bConnectDB,  // specifies whether or not to connect to the DB upon opening the catalog
        const _variant_t & vCatalogCopy  // ignore this...always vtMissing for our purposes);<P>HRESULT IAppAuto::ConnectDatabase (
        const _variant_t & szDBUserID,
        const _variant_t & szDBPassword );<P>HRESULT IAppAuto::DisconnectDatabase ( );<P>HRESULT IAppAuto::Quit ( );<P>// This causes the report to be opened and run (query the DB), if the DB was connected when the catalog was opened
IImpDocPtr IAppAuto::OpenReport (
        _bstr_t szReportFileName,
        const _variant_t & szPromptValues );<P>// This will cause the report to be opened, but will NOT query the DB
IImpDocPtr IAppAuto::OpenReportNoExecute (
        _bstr_t szReportName );<P>HRESULT IAppAuto::CloseCatalog ( );<P>HRESULT IImpDoc::Reexecute ( );<P>HRESULT IImpDoc::Close ( );<P>IImpPDFPublisherPtr IImpDoc::PublishPDF ( );<P>VARIANT_BOOL ImpPDFPublisher::Publish (
        _bstr_t szFileName );

Alright, so a typical use would seem to be:

code:<HR>
Code:
#import "C:\Program Files\Cognos\cer1\bin\impclient.tlb" rename("FolderItem", "ImpromptuFolderItem")<P>void foo()
{
        ImpromptuClient55::IAppAutoPtr App=NULL;
        App.CreateInstance("CognosImpromptu.Application");
        App->OpenCatalog("C:\\MY_CATALOG.CAT", "User", vtMissing, "DB_USER_NAME", "DB_PASSWORD", true, vtMissing);<P>        ImpromptuClient55::IImpDocPtr Doc=App->OpenReport("C:\\MY_REPORT.IMR", "Prompt1Value|Prompt2Value|Prompt3Value|...");<P>        ImpromptuClient55::IImpPDFPublisherPtr PDF=Doc->PublishPDF();<P>        PDF->Publish("C:\\OUTPUT.PDF");<P>        Doc->Close();
        App->CloseCatalog();
        App->Quit();<P>        return;
}<P>int main()
{
        CoInitialize(NULL);<P>        foo();<P>        CoUninitialize();<P>        return 0;
}

This works great. Now, if we switch to

code:<HR>
Code:
<P>#import blahblah<P>void foo()
{
        //as before
}<P>unsigned int __stdcall Thread(void *Unused)
{
        CoInitialize();
        foo();
        CoUninitialize();<P>        return 0;
}<P>int main()
{
        unsigned int ThreadAID=0, ThreadBID=0, ThreadCID=0, ThreadDID=0, ThreadEID=0, ThreadFID=0, ThreadGID=0, ThreadHID=0;<P>        HANDLE ThreadAHandle, ThreadBHandle, ThreadCHandle, ThreadDHandle, ThreadEHandle, ThreadFHandle, ThreadGHandle, ThreadHHandle;<P>        bool ThreadADead=false, ThreadBDead=false, ThreadCDead=false, ThreadDDead=false, ThreadEDead=false, ThreadFDead=false, ThreadGDead=false, ThreadHDead=false;
	<P>        ThreadAHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('A'), 0, &ThreadAID);
        ThreadBHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('B'), 0, &ThreadBID);
        ThreadCHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('C'), 0, &ThreadCID);
        ThreadDHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('D'), 0, &ThreadDID);
        ThreadEHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('E'), 0, &ThreadEID);
        ThreadFHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('F'), 0, &ThreadFID);
        ThreadGHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('G'), 0, &ThreadGID);
        ThreadHHandle=(HANDLE)_beginthreadex(NULL, 0, Thread, (void *)('H'), 0, &ThreadHID);<P>	while (!ThreadADead || !ThreadBDead || !ThreadCDead || !ThreadDDead || !ThreadEDead || !ThreadFDead || !ThreadGDead || !ThreadHDead)
        {
                DWORD ThreadStatus;<P>                if (!ThreadADead)
                {
                        GetExitCodeThread(ThreadAHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread A died." << std::endl;
				CloseHandle(ThreadAHandle);
				ThreadADead=true;
			}
		}
		
		if (!ThreadBDead)
		{
			GetExitCodeThread(ThreadBHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread B died." << std::endl;
				CloseHandle(ThreadBHandle);
				ThreadBDead=true;
			}
		}<P>		if (!ThreadCDead)
		{
			GetExitCodeThread(ThreadCHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread C died." << std::endl;
				CloseHandle(ThreadCHandle);
				ThreadCDead=true;
			}
		}
		
		if (!ThreadDDead)
		{
			GetExitCodeThread(ThreadDHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread D died." << std::endl;
				CloseHandle(ThreadDHandle);
				ThreadDDead=true;
			}
		}<P>		
		if (!ThreadEDead)
		{
			GetExitCodeThread(ThreadEHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread E died." << std::endl;
				CloseHandle(ThreadEHandle);
				ThreadEDead=true;
			}
		}
		
		if (!ThreadFDead)
		{
			GetExitCodeThread(ThreadFHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread F died." << std::endl;
				CloseHandle(ThreadFHandle);
				ThreadFDead=true;
			}
		}<P>		if (!ThreadGDead)
		{
			GetExitCodeThread(ThreadGHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread G died." << std::endl;
				CloseHandle(ThreadGHandle);
				ThreadGDead=true;
			}
		}
		
		if (!ThreadHDead)
		{
			GetExitCodeThread(ThreadHHandle, &ThreadStatus);
			if (ThreadStatus!=STILL_ACTIVE)
			{
				std::cout << "Thread H died." << std::endl;
				CloseHandle(ThreadHHandle);
				ThreadHDead=true;
			}
		}
		
		Sleep(1000);
	}<P>        return 0;
}

then the mysterious blocking occurs. The threads do indeed seem to be synchronizing; I get a dialog box about the application being busy, with an option to switch to it, to ignore it, or to abort (or something to that affect). I always choose "ignore." I get exactly 7 of these boxes. Making the application visible lets me see that, yes, in fact there are 8 instances being started, but only one is doing anything at any given time.

Change to:

code:<HR>
Code:
#import blahblah<P>void foo()
{
        ImpromptuClient55::IAppAutoPtr App=NULL;
        App.CreateInstance("CognosImpromptu.Application");
        App->Visible(true);<P>        App->OpenCatalog("C:\\MY_CATALOG.CAT", "User", vtMissing, "DB_USER_NAME", "DB_PASSWORD", true, vtMissing);<P>        //DO NOT EXECUTE the report yet
        ImpromptuClient55::IImpDocPtr Doc=App->OpenReportNoExecute("C:\\MY_REPORT.IMR");<P>        //execute the report NOW
        Doc->Reexecute();<P>        ImpromptuClient55::IImpPDFPublisherPtr PDF=Doc->PublishPDF();<P>        PDF->Publish("C:\\OUTPUT.PDF");<P>        Doc->Close();
        App->CloseCatalog();
        App->Quit();<P>        return;
}<P>unsigned int __stdcall Thread(void *Unused)
{
        //as before
}<P>int main()
{
        //as before
}

and all 8 instances work properly. One problem: our reports all need prompts, and there's no way (I've found) to specify the prompt values when opening the reports this way. Change foo() to
code:<HR>
Code:
void foo()
{
        ImpromptuClient55::IAppAutoPtr App=NULL;
        App.CreateInstance("CognosImpromptu.Application");
        App->Visible(true);<P>        //DO NOT connect to the DB yet
        App->OpenCatalog("C:\\MY_CATALOG.CAT", "User", vtMissing, vtMissing, vtMissing, false, vtMissing);<P>        ImpromptuClient55::IImpDocPtr Doc=App->OpenReport("C:\\MY_REPORT.IMR", "Prompt1Value|Prompt2Value|Prompt3Value|...");<P>        App->ConnectDatabase("DB_USERID", "DB_PASSWORD");<P>        //execute the report NOW
        Doc->Reexecute();<P>        ImpromptuClient55::IImpPDFPublisherPtr PDF=Doc->PublishPDF();<P>        PDF->Publish("C:\\OUTPUT.PDF");<P>        Doc->Close();
        App->CloseCatalog();
        App->Quit();<P>        return;
}
and all 8 instances work, plus we get to specify prompts. It also looks as if multiple instances are "busy" at the same time.

Odd, no? Why do you suppose re-arranging the method calls affects the blocking?

This is all fine and dandy, but when I roll this change into my service, something is still dying somewhere...I'm working on tracking that down now.

Jet, thanks for the tips. Hopefully my description will make something stand out at you. I did have one question, though: I thought the registry setting specifying the threading model was only valid for in-proc servers?

COM can be quite confusing and convoluted. :(

True dat. True dat.
 

TheJet

Ars Praefectus
4,598
Subscriptor++
Jet, thanks for the tips. Hopefully my description will make something stand out at you. I did have one question, though: I thought the registry setting specifying the threading model was only valid for in-proc servers?

This may be true, like I said, about every time I think I've got my mind wrapped around these things, I miss one important piece that hoses everything up ;) That's why I have to get these things written down for good (and why I'm loving .NET so much, everything is relatively straightfoward).

Hrm... The one thing I did notice (and this may just have been an oversight in your transcription of the code), but there is no argument on the Coinitialize() method in your main Thread() routine. Don't know if this makes a difference or not, just thought I'd mention it.

Also, it could be that the applications are fighting for a database resource of some sort. How is the database information setup, does it use ADO/RDO/DAO/etc to contact a database backend? My guess is that the application does something differently in the OpenExecute*() and the ReExecute() methods. Have you tried contacting the creators of the component for help on this? I've sometimes found that 5 minutes on the phone with support can solve 4 hours of head-vs.-wall time. Then again, I've had the opposite as well ;)

It could also be that the threads are blocking on the method calls which open the database. That would mean that if the call to OpenExecute() causes the database to be opened (say in an environment where the connection isn't opened until it's needed), that the thread wouldn't unblock until the end of that method call for some reason... Sounds kinda weird, and I don't think that's it, but who knows...

TheJet
 

Liam

Ars Scholae Palatinae
618
there is no argument on the Coinitialize() method in your main Thread() routine

Yes there is, it's just hiding. ;) I forgot it in my sample, but I'm using CoInitialize(NULL), and I've also tried CoInitializeEx(NULL, COINIT_MULTITHREADED). AFAIR, CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) is the same as CoInitialize(NULL).

Umm, the DB is Oracle, and I believe Impromptu uses some proprietary lower-level driver (than say, ODBC) to access it.

I suppose "blocking" is the wrong term to use (yugami actually corrected me waaay up at the top); when everything breaks, it's actually because the threads are all deadlocked. I.e. nothing ever gets _un_blocked.

I made some headway this afternoon; it seems that Impromptu was locking the report files. Despite the fact that I ran my 8 thread test with all threads opening exactly the same catalog and report files and it worked just fine, sunspot activity (or something) has caused subsequent tests to fail whenever multiple threads were trying to access the same report. I've modified it a bit so that each thread makes its own copy of the report, and this seems to have helped for the time being. I'm gradually bludgeoning it into submission, which is not a debugging style I tend to prefer, but I suppose I can't complain with the results.

Cognos sells a program called Impromptu WebReports that does precisely what our program is doing, so I can't imagine them being toooo helpful. I actually posted something to their public newsgroup, but I haven't had much of a response. The wall and I are good old pals by now, but I console myself by saying that I remember things better after they've been hammered into my skull.

What's this, you say? .NET doesn't suck? I've had this Beta 2 DVD laying around for about 6 months that came with Dr. Frobb's...should I try it out? :D

Werd.
L

[This message was edited by Liam on December 29, 2001 at 05:25.]
 
Status
Not open for further replies.