LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

calling from shared library hangs

Hi,

I have a dll compiled under LV2011 and want to use it inside CVI routines (CVI2010 under Win7)

In general all looks very fine but dialog boxes. Whenever there is a message to be popped up I see only its blank window and a CVI program hangs.

I created a dummy function in this dll with only a dialog box, just to check whether something else doesn't influence this. Works the same, I mean hangs. No text is displayed, just freezed empty dialog window.

 

This dll was running correctly previously, when compiled under LV7.1 and running under CVI2010 under WinXP.

 

Is there any solution for such behaviour??

 

Thanks for help.

0 Kudos
Message 1 of 9
(4,182 Views)

Hi Slawomir,

 

Can you send me please the code you used to reproduce the problem?

I'll take a look on it, and hope we'll find some solution 😉

 

Best Regards,

Tamas

0 Kudos
Message 2 of 9
(4,146 Views)

Hi,

I attached simple CVI environment with compiled dll to be called. There is also problematic vi included.

Please take a look, maybe you can figure out something.

0 Kudos
Message 3 of 9
(4,128 Views)

Hello,

 

I guess this happens because the dll doesn't pass the full information about the user dialogs that are defined by LV 2011.

Why don't you defined the user dialog in CVI? What is it your final goal?

 

Kind regards,

Ion R.

0 Kudos
Message 4 of 9
(4,120 Views)

Hi ion.rosca

what do you mean by:


@ion.rosca wrote:
I guess this happens because the dll doesn't pass the full information about the user dialogs that are defined by LV 2011.


A comment in dialog box is not a result of functions in my dll. Dialogs appear during the execution and impact the further steps.

So obviously I need them be called from LV.

I think however that standard two button dialog box should not be problematic for CVI to be handled.

0 Kudos
Message 5 of 9
(4,110 Views)

When you need to show the LabVIEW UI in a DLL function, it cannot be running in the main thread. In LabVIEW, you would normally set the Call Library Function node to use "Run in any thread" instead of "Run in UI thread". In CVI, or other text based languages, you must spawn a new thread an run the DLL function there. The following code should help you out:

 

int CVICALLBACK ThreadFunction (void *functionData)
{
	 int i=0;
	 i = TestKomentarza(4,"jdksjkdjslk");  
	 return 0;
}

  		

int CVICALLBACK test (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	CmtThreadFunctionID myThread;
	switch (event)
	{
		case EVENT_COMMIT:

			CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,
										   ThreadFunction, NULL, &myThread);   
			break;
	}
	return 0;
}

 

National Instruments
0 Kudos
Message 6 of 9
(4,101 Views)

Hi,

It took some time until I notice what is happening.

I added a wait for a thread completion and thread release so it seems to work as it was before I mean perform a compete operation.

 

int CVICALLBACK ThreadFunction (void *functionData)
{
	 int i=0;
	 i = TestKomentarza(4,"jdksjkdjslk");  
	 return 0;
}
int CVICALLBACK test (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	CmtThreadFunctionID myThread;
	switch (event)
	{
		case EVENT_COMMIT:

			CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE, ThreadFunction, NULL, &myThread);   
			CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE, myThread, OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
			CmtReleaseThreadPoolFunctionID (DEFAULT_THREAD_POOL_HANDLE, myThread);
			break;
	}
	return 0;
}

 

For some time I thought it works ok only at first call. ThreadFunction which is TestKomentarza has been called with parameter "4" which causes to call three button dialog box. When I first call it, it popped up well, but the second call gave as a result only main window not responding. I thought it freezed, but finally I found the popup window in a background. I had to minimize any other program window and that brought the pop up message to the front and can be usable. Every next call make the message window to pop up under a main program window, in background.

 

Depending on which type of message box is called this is the behavior:

0 - display message to user express vi  - works ok

1 - one button dialog box                            - works ok

2 - prompt user for input                             - first time ok, then it pops up in background

3 - two button dialog box                            - works ok

4 - three button dialog box                         - first time ok, then it pops up in background

It is very strange behavior.

By the way, whenever you switch to other program when message is displayed, and switch back to your program, the message window disappears, but indeed it hides under your program window. There is no indicator on taskbar that additional window is shown it is not possible to recall it. I have to minimize any other program window that is currently running on my PC and that brings the message back to front.

Could you check also this?

 

 

I figure out that a solution for my problem would be to create another dll, this time under CVI. In this dll I would make callings of my functions inside threads, passing all the data using a structure.

Or maybe would be better to prepare the functions in threads already in LV?

Could you advise me on which method would be better?

 

 

As I mentioned at the beginning it was all working fine under LV7.1, what has change and when that it now requires threads?

 

 

0 Kudos
Message 7 of 9
(4,071 Views)

Hello !

 

can anyone please help me with a dll issue.I have a c++ class that peforms certain functions.i have created a dll that creates an object of this class to access functions to this class that can be used in labview.now when i run this dll in parallel using call library node function.the results are not correct.for example if my class performs addition of two numbers the 2-separate instances of the dll in labview would mix the addition result with each other.what do i need to do in order to run the dll in parallel.

 

Thank you.

0 Kudos
Message 8 of 9
(3,949 Views)

Hello ni_beginner,

original thread referenced some aspects of calling a LV dll from CVI, and that's why it is in this CVI board.

Your question specifically refers to LabVIEW and should therefore be better posted in that forum



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 9 of 9
(3,940 Views)