Author Topic: keeping code running in main form when new forms are opened in c#  (Read 469 times)

0 Members and 1 Guest are viewing this topic.

Offline snarkysparkyTopic starter

  • Frequent Contributor
  • **
  • Posts: 418
  • Country: us
In my main form I have a timer that is doing periodic work that I want to keep happening when a new form is opened.

The work involves checking a TCP listener for connections as well as other non GUI communicating with hardware.

If a modal form is opened does this timer in the parent form keep running even though the parent form GUI is inactive ?

Thanks
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 12406
  • Country: us
Re: keeping code running in main form when new forms are opened in c#
« Reply #1 on: April 08, 2022, 02:33:06 pm »
Why don't you test it?

Arrange for the timer to write periodic messages out to the console window (or debug window), and then watch to see if these messages keep coming while the modal form is open.
 

Offline snarkysparkyTopic starter

  • Frequent Contributor
  • **
  • Posts: 418
  • Country: us
Re: keeping code running in main form when new forms are opened in c#
« Reply #2 on: April 08, 2022, 02:39:16 pm »
I have tested.  Timer does keep going.  But I really really would like to know that this is the expected result and not just a fluke.

Thanks
 

Offline zzattack

  • Regular Contributor
  • *
  • Posts: 135
  • Country: nl
Re: keeping code running in main form when new forms are opened in c#
« Reply #3 on: April 08, 2022, 02:50:41 pm »
Opening a modal form on top of another one does not block the obscured one's message loop, so yes this is as expected.
 
The following users thanked this post: snarkysparky


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf