Posting a windows message

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I'm new to the compact framework so this may be a very stupid question.
I'd like to synchronize my sqlserverce database by selecting a menu
option. I've created the menu option and put the sync code in the
Menu_Click() method. This works fine except the menu stays open and
visible while the database syncs. I'd rather the menu go away. I
tried using delegates/events but it seems that this uses the underlying
windows SendMesssage instead of PostMessage, so the menu remains open
and visible on the form while the database syncs. Is it possible to
post a windows message in the Menu_Click() method, letting the Click()
method complete, the menu item disappear, and then the process the
posted windows message in a method that syncs the database?

Thanks.

-Chris
 
You should not blog the UI thread with long running operations and it sounds
like that is what you are doing. Instead put the work in its own thread.

If you want to keep your current approach, try sticking an
Application.DoEvents in the menu click event handler (at the top).

Cheers
Daniel
 
Back
Top