LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CreateEvent() returns 0

Solved!
Go to solution

Hello everyone,

 

I am using this code to call CreateEvent function:

 CreateEvent.png

 

It works fine, but not always. When I run for the first time, it returns correct, nonzero value. But when I call it second time, the return value is 0. Then, calling it for the third time will result in returning nonzero, and 4th - zero again etc.

 

Using CloseHandle() function between calls doesn't help.

0 Kudos
Message 1 of 17
(5,141 Views)

Hi turbolek,

 

please stick with one thread for this topic!

 

As long as you only post images nobody is able to help you! We don't know which functions you are calling nor do we know the settings you made in the CLFN!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 17
(5,138 Views)

Sorry, you're right. I didn't want to post all huge code, so thought that images will be the best solution, but now I've created new VI, including just the part I am talking about.

So, in attached VI there's the same issue than described before - 2nd, 4th, etc. run results in returning 0.

0 Kudos
Message 3 of 17
(5,132 Views)

@turbolek wrote:

Sorry, you're right. I didn't want to post all huge code, so thought that images will be the best solution, but now I've created new VI, including just the part I am talking about.

So, in attached VI there's the same issue than described before - 2nd, 4th, etc. run results in returning 0.


He's also right that you should stick to one thread.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 17
(5,127 Views)

OK, I should have but now I don't know how to merge this topics or delete one of them.

0 Kudos
Message 5 of 17
(5,118 Views)

Hi turbolek,

 

I don't know how to merge this topics or delete one of them.

You cannot merge or delete threads, this is only upto the forum admins. You can use links in your messages to indicate a discussion was continued in a different thread (as I already have done in your other thread.)

 

Did you read the MSDN entry on CreateEventA()? It says:

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 17
(5,108 Views)

GetLastError returns 998, but I can't find a complete solution of this issue neither on this board nor anywhere else. 

0 Kudos
Message 7 of 17
(5,073 Views)
Solution
Accepted by topic author turbolek

You're not calling the function correctly.

Use unsigned-32-bit values for first and fourth inputs, and unsigned bytes (8-bit) values for the second and third inputs. Nothing by pointer.

When you correct for this, it works every time

Thoric (CLA, CLED, CTD and LabVIEW Champion)


Message 8 of 17
(5,069 Views)

It solved it, thanks :]

0 Kudos
Message 9 of 17
(5,066 Views)

OK, so here comes another question from that similar topic mentioned before.

 

Whenever I try to call WaitForSingleObject function using an Event Handle that I received from just solved piece of code, LabVIEW immediately shuts down. There are not any error reports or something.
I guess I am calling it wrong again as I couldn't find any working example of using this function in LabVIEW. The second DWORD parameter is especially tricky, because I don't have any idea how to pass INFINITE (described HERE) value using LabVIEW. 

 

Can somebody share a working example of WaitForSingleObject use in LabVIEW, please?

0 Kudos
Message 10 of 17
(5,050 Views)