LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Multiple RunUserInterface() in LabWindows

Hi,

I work with LabWindows/CVi 5.5, Win2k and Delphi 5.

I've got a threaded application in Delphi that start multiple export methods in a LabWindows DLL. Everything work fine until the time I close the LabWindows user interfaces. If I don't close them in the inverse order that they were created I get an Access Violation in cvirte.dll.

I'll explain exactly what I do :
- I got a Delphi application that start multiple threads.
- Each thread do a load library of "MyLW_DLL.dll".
- Each thread call an export method of the "MyLW_DLL.dll" (sometime different function, sometime the same, but the problem is there in every cases).
- The export functions do a LoadpanelEx of "MyUser.uir" (every export
ed function use the same user interface).
- After that the export functions does a RunUserInterface and wait for the user interface to be close. (user has multiple thing to do to the interface).

- Here come the problems : if I close the user interface in the reverse order that they were created everything is OK (no problem), but if I close them in the order they were created or in a mix order I get an access violation in cvirte.dll.

I'll try to clear this up, let's say I have 3 exported methods "MyTest1", "MyTest2", "MyTest3".
- From my Delphi application I got 3 thread that do the call in this sequence :
"MyTest1", "MyTest2", "MyTest3".
- If I close the user interfaces in this order "MyTest3", "MyTest2", "Mytest1" everything is ok.
- But if I close them in this order "MyTest1", "MyTest2", "Mytest3" or in this order "MyTest2", "MyTest3", "Mytest1" I get an access violation in cvirte.dll at address 0x0137057B, for a try to read the address 0x0801524E.

The calls to RunUser
Interface() seems to be nested and if you don't close them in the right order everything crash. I don't even catch an exception in my delphi applciation everything just crash down directly.

Thanks in advance,

Gilles
0 Kudos
Message 1 of 2
(3,385 Views)
Dear Gilles,
in my opinion you should have only one RunUserInterface in your program, 'cause this is the starting point of all event processing in CVI. Running multiple user interfaces at the same time can give you some strange results, like those you are experiencing.
So I think the best would be that sequence:
- start your CVI program and RunUserInterface
- inside it call the separate routines in your dll
Or another way: in your application keep trace in a global variable wether the userinterface has already started and of number of processes requiring it, start it only if it has not been yet and close it only if you are the last process using it.
Sorry for generic response: I have no experience in calling external code in CVI, but the principle slould be this o
ne.
I hope I help you
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(3,385 Views)