LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

C# Constructor being called multiple times when I run my VI

Hi all,

 

We are runing LabVIEW 8.51 in the lab and have been using a bodged together C++ DLL which was crude but got the job done. Now looking at rewriting it in C# to make it easier to maintain and support long term.

Ive got the C# DLL appearing in Labview and can happily call my test functions from the VI to prove both the DLL inputs and outputs are working fine (the simple input a number, add 1 and return result type of code).

However, this DLL will end up managing a Serial port connection so the contstructor must only be called once as its responsible for making my .net serial port object. Ive added a text log message in the constructor and have found that just running the VI is causing the constructor to be called at least 5 times a second. There is no user input causing this....just running the VI.

Both VI and C# source is attached.

Any ideas folks? Im a complete newbie at LabVIEW having taken this on from another developer.

 

The VI is in \Release and this is where the Log file is generated.

 

Mat

0 Kudos
Message 1 of 5
(2,376 Views)

Well, I may not be Sherlock Holmes, but I think the fact that you have your constructor inside the loop is probably a pretty good clue as to why your constructor is being called all the time.

0 Kudos
Message 2 of 5
(2,371 Views)

As I said, im a total LabView newbie......loop?

0 Kudos
Message 3 of 5
(2,368 Views)

Ummmm.. yes, loop. That big thing gray rectangle that surrounds your code. Have you done any LabVIEW tutorials? That isn't even a LabVIEW question, but a basic programming question.

 

To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

0 Kudos
Message 4 of 5
(2,365 Views)

As I said in the intro, Ive taken on maintance of the code from another developer who has left the company. So havent a clue about LabVIEW and am learning it as I go.

So yeah...moved outside box and everything is good. Thanks for your help!

0 Kudos
Message 5 of 5
(2,363 Views)