question

BenJSamson-3260 avatar image
0 Votes"
BenJSamson-3260 asked Viorel-1 commented

Program lags when using executable and not having VS open.

I'm working on a small Windows Forms App (.NET Framework) project.
It mainly consists of a backgroundworker. The backgroundworker starts by breifly listening for a CAN message with a certain ID. The data part of the message is a byte array where each value indicates how far a physical lever has been pulled (there are 8 levers and the array contains 8 bytes). It then uses a ProgressChanged method to update 8 labels with the corresponding lever data.

The issue I'm having is that when I run the program, by using the executable generated from building the project,
and pull a lever, there is an extremely long delay (30+ sec) before the levers label value is changed. However, if I have VS open in the background (could be a completely different/ empty project) I get no lagg, and the labels are updated pretty much instantly. I can also run the program directly from VS without any issues. Does anyone know why this happens?

I have seen that the lever values are updated instantly on the CAN bus when a lever is pulled, so the lagg is somewhere between me reading the bus and displaying the values in the form.

vs-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


In order to check that the messages arrive in time, you can temporarily add a Console.Beep() in your listening code and comment other parts. You should hear some beeps when lever is pulled.

Maybe also show some details about the background worker and ProgressChanged handler.

0 Votes 0 ·

1 Answer

AnnaXiu-MSFT avatar image
0 Votes"
AnnaXiu-MSFT answered

Hi @BenJSamson-3260 ,

Welcome to Microsoft Q&A!

According to your description, I suppose it may be related to your project or your machine.

Have you tried to run your project on other machines?
You can check if there are third party software installed on your machine or not. And that may affect the performance of executables outside Visual Studio.

Sincerely,
Anna


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.