Click here to Skip to main content
15,903,203 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Design Patterns (Abstraction etc.) [modified] Pin
Josh Smith14-Jun-06 7:15
Josh Smith14-Jun-06 7:15 
GeneralRe: C# Design Patterns (Abstraction etc.) Pin
Mr. VB.NET14-Jun-06 10:56
Mr. VB.NET14-Jun-06 10:56 
GeneralRe: C# Design Patterns (Abstraction etc.) Pin
Kevin McFarlane14-Jun-06 23:19
Kevin McFarlane14-Jun-06 23:19 
AnswerRe: C# Design Patterns (Abstraction etc.) Pin
Kevin McFarlane14-Jun-06 6:02
Kevin McFarlane14-Jun-06 6:02 
QuestionInstaller Language settings [modified] Pin
Endren14-Jun-06 5:20
Endren14-Jun-06 5:20 
QuestionEvents, Threads & BindingSource Pin
iswoolley14-Jun-06 5:14
iswoolley14-Jun-06 5:14 
AnswerRe: Events, Threads & BindingSource Pin
Mr. VB.NET14-Jun-06 5:34
Mr. VB.NET14-Jun-06 5:34 
GeneralRe: Events, Threads & BindingSource Pin
iswoolley14-Jun-06 6:59
iswoolley14-Jun-06 6:59 
Just to clarrify: I should write my own event handling code in the form, which listens to PropertyChanged events from the monitor object, and then calls methods (via Invoke) on the label to update the text?

Something like...

  public partial class Form1 : Form<br />
    {<br />
    PortMonitor monitor;<br />
    <br />
    public Form1 ()<br />
      {<br />
      InitializeComponent();<br />
<br />
      monitor = new PortMonitor();<br />
      monitor.PropertyChanged += new PropertyChangedEventHandler(monitor_PropertyChanged);<br />
      }<br />
<br />
     public void monitor_PropertyChanged (object sender,PropertyChangedEventArgs e)<br />
{<br />
if(InvokeRequired)<br />
{<br />
BeginInvoke(new PropertyChangedEventHandler(monitor_PropertyChanged), sender, e);<br />
}<br />
else<br />
{<br />
label1.Text=monitor.Rate;<br />
}<br />
}<br />
}


This seems like a knarly way of pushing data out to the UI, as it bypasses the BindingSource and negates the usefullness of the DataBindings in the Label. Isn't the BindingSource meant to be in the middle there handling all this inter-thread malarky?

I really like the simplicity of a one liner like:

progressBar1.DataBindings.Add("Value",myBindingSource,"FileTransferProgress");

Isn't there some way I can handle the invokation stuff in the NotifyPropertyChanged method of my monitoring class? Something like:

private void NotifyPropertyChanged (string property)<br />
      {<br />
      if(PropertyChanged != null)<br />
        {<br />
        Control target = (Control)PropertyChanged.Target;<br />
        if(target.InvokeRequired)<br />
          {<br />
          target.BeginInvoke(new PropertyChangedEventHandler(PropertyChanged),this,new PropertyChangedEventArgs(property));<br />
          }<br />
        else<br />
          {<br />
          PropertyChanged(this,new PropertyChangedEventArgs(property));<br />
          }<br />
        }<br />
      }


Would that, or something similar, work?

Iain
AnswerRe: Events, Threads & BindingSource Pin
Mr. VB.NET14-Jun-06 6:32
Mr. VB.NET14-Jun-06 6:32 
AnswerRe: Events, Threads & BindingSource Pin
Leslie Sanford14-Jun-06 10:20
Leslie Sanford14-Jun-06 10:20 
AnswerRe: Events, Threads & BindingSource Pin
iswoolley19-Jun-06 5:45
iswoolley19-Jun-06 5:45 
Questionwhich datatype will be appropriate for Ratio calculation in C# Pin
kumar.bs14-Jun-06 5:12
kumar.bs14-Jun-06 5:12 
AnswerRe: which datatype will be appropriate for Ratio calculation in C# Pin
User 665814-Jun-06 5:20
User 665814-Jun-06 5:20 
AnswerRe: which datatype will be appropriate for Ratio calculation in C# Pin
albCode14-Jun-06 5:21
albCode14-Jun-06 5:21 
GeneralRe: which datatype will be appropriate for Ratio calculation in C# Pin
MCSD-Gandalf14-Jun-06 5:50
MCSD-Gandalf14-Jun-06 5:50 
QuestionC++ -> C# VirtualAllocEx! Pin
suguimoto14-Jun-06 3:59
suguimoto14-Jun-06 3:59 
AnswerRe: C++ -> C# VirtualAllocEx! Pin
Josh Smith14-Jun-06 4:21
Josh Smith14-Jun-06 4:21 
GeneralRe: C++ -> C# VirtualAllocEx! Pin
suguimoto14-Jun-06 4:34
suguimoto14-Jun-06 4:34 
JokeTabStrip Control Downside Pin
Sravan Krishna14-Jun-06 3:30
Sravan Krishna14-Jun-06 3:30 
JokeRe: TabStrip Control Downside Pin
Mairaaj Khan14-Jun-06 3:39
professionalMairaaj Khan14-Jun-06 3:39 
GeneralRe: TabStrip Control Downside Pin
Sravan Krishna14-Jun-06 4:23
Sravan Krishna14-Jun-06 4:23 
QuestionMulticolumn Drop Down in DataGridView Pin
i_islamian14-Jun-06 3:28
i_islamian14-Jun-06 3:28 
QuestionAdding a TracBar to a ToolStripMemuItem Pin
smcneese14-Jun-06 3:07
smcneese14-Jun-06 3:07 
Questionthe Value of the Last ID ... Pin
mostafa_h14-Jun-06 3:01
mostafa_h14-Jun-06 3:01 
AnswerRe: the Value of the Last ID ... Pin
Tamimi - Code14-Jun-06 3:17
Tamimi - Code14-Jun-06 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.