Click here to Skip to main content
16,004,507 members

Comments by Luc Pattyn (Top 200 by date)

Luc Pattyn 4-Sep-24 8:17am View    
a Graphics may well be the most expensive object around, and you don't dispose of Graph1??

and you create a new Font each time around? without disposing of it?

and what is "Brush"???

If this code runs at all, it will be sluggish and won't last long when you move something over the PictureBox causing a barrage of Paint events.
Luc Pattyn 4-Sep-24 8:12am View    
you should not (have a using statement) dispose of the bmp that is currently in use by PictureBox1, you should dispose of the previous bmp, the one PictureBox1 will no longer use (if any) when you assign a new image.

:)
Luc Pattyn 4-Sep-24 8:11am View    
Deleted
you should not (have a using statement) dispose of the bmp that is currently in use by PictureBox1, you should dispose of the previous bmp, the one PictureBox1 will no longer use (if any) when you assign a new image.

:)
Luc Pattyn 14-Aug-24 21:14pm View    
as modbus is a master-slave communication protocol, the only way of detecting a state change in the slave is by the master executing a polling mechanism (your "continuous read"). There are many ways to implement that, e.g. with threads, with a BackGroundWorker, and with timers. The timer I suggested is the simplest assuming it meets your requirements. And whatever you choose, you have to balance latency with CPU load as you are polling, not waiting for an event being signaled. Obviously my 100 msec is just an example, you can shorten that period, however you wanted to "show the change of value" so anything between 20 and 100 msec seems fine to me.

:)
Luc Pattyn 4-Jul-24 17:08pm View    
"it didn't work" is not informative.

did you check my statement "ldexp(pcg32_random_r(&rng), -32); will result in [-0.5, +0.5)"?
did you check my statement "ldexp(pcg32_random_r(&rng) & 0x7FFFFFFF, -31); will result in [0, 1)"?
You wrote "I started to use the PCG generator ... because the standard generator wasn't enough." So I assume you know how to check and evaluate a random generator.