0

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.

nightman
  • 11
  • 2
  • This is not reproducible – T.S. Apr 28 '21 at 00:20
  • A guess is that you are missing CAN frames. Control systems should be designed/configured to send data continuously and not just on data change. Anyway, you need to clarify how you connect the PC fluff to a CAN bus. Is this some embedded Windows thing, or are you using some CAN board in the PC or a CAN-to-USB adapter (which one)? – Lundin Apr 28 '21 at 08:57
  • Hi, thanks for your answer and sorry for the late response. It seems my lagging issue was related to something called "platform/system timer resolution". The solution suggested for a similar problem in this thread: https://stackoverflow.com/questions/16612236/why-is-my-c-sharp-program-faster-in-a-profiler worked for me. – nightman Jul 01 '21 at 12:14

0 Answers0