C
Chris
Hello,
I encountered a severe Problem with a Compact Framework Program I wrote in
C#.
I have a Form with an ListBox Object on it. On Button-Click, a Method
Object.GetData() is called which takes a relatively long time to return. The
result is then given to the Listbox by:
ListBox.Datasource = Object.GetData();
Additionally I have a Threading.Timer Object that issues frequent events. I
have a TimerCallback-Delegate and an appropriate OnTimer Delegate Function
implementation which is called each time the timer expires. A State is
maintained in a special object which I want to be observed by the GUI.
The timer expiry is communicated to the GUI by applying the Observer
Pattern.
(The GUI first registers with the State Object, and each time the State
Object gets updated, it calls the Notification-Method of its' obsever (via
registration information, which is a simple object-reference). The observer
(the GUI) then updates a Label with the according State.
So far so good. Everything works fine. But as I press the update button of
the listbox around the time when the timer gets updated (the label), the
application seems to hang and never return from the long call to
Object.GetDate();
So what is the issue? May there be a race condition?
Do I need to have my Object.GetDate() called asynchronously????
How can I get a clean separation from the GUI?
I'd appreciate any help!
regards
Chris
In my opinion, there can be no problem with that because
I encountered a severe Problem with a Compact Framework Program I wrote in
C#.
I have a Form with an ListBox Object on it. On Button-Click, a Method
Object.GetData() is called which takes a relatively long time to return. The
result is then given to the Listbox by:
ListBox.Datasource = Object.GetData();
Additionally I have a Threading.Timer Object that issues frequent events. I
have a TimerCallback-Delegate and an appropriate OnTimer Delegate Function
implementation which is called each time the timer expires. A State is
maintained in a special object which I want to be observed by the GUI.
The timer expiry is communicated to the GUI by applying the Observer
Pattern.
(The GUI first registers with the State Object, and each time the State
Object gets updated, it calls the Notification-Method of its' obsever (via
registration information, which is a simple object-reference). The observer
(the GUI) then updates a Label with the according State.
So far so good. Everything works fine. But as I press the update button of
the listbox around the time when the timer gets updated (the label), the
application seems to hang and never return from the long call to
Object.GetDate();
So what is the issue? May there be a race condition?
Do I need to have my Object.GetDate() called asynchronously????
How can I get a clean separation from the GUI?
I'd appreciate any help!
regards
Chris
In my opinion, there can be no problem with that because