S
Scooby
Okay, I'm a noob at C# and microsoft's IDE, but have a fairly long history
of programming (with, cough, Delphi). I'm writing a mobile app in C# with
Visual Studio 2005. I think there must be something fundamental that I'm
missing and could use a pointer in the right direction.
Below is a simplified version of a test program. I am using a namespace
provided from a dll file (used as MyNameSpace here). Anyway, I create a
component from within, which has a callback method. When I initiate the
process (button1_click), the callback happens just fine. However, I can not
seem to update any of the controls on the MainForm. As you will see, my
callback method has a call to Update Values. The call happens, but the
labels never get updated. However, initiating Button2_Click, will then call
UpdateValues and the labels will be updated.
It almost seems like my component is referencing a different instance of
MainForm. I would suspect this would be the behavior if I had not preceeded
my component with 'this' when creating it or the callback method. But, I
thought I got that right.
Anyway, anyone have an clues? Thanks for the help
Jim
============================================================
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MyNameSpace;
namespace MyTestApp
{
public partial class MainForm : Form
{
private MyClass MyVar;
public MainForm()
{
InitializeComponent();
Int Val1, Val2;
this.MyVar = new MyClass();
this.MyVar.OnResponse += new
MyClass.OnResponseHandler(this.MyResponseHandler);
}
private void button1_Click(object sender, EventArgs e)
{
MyVar.SendRequest();
}
private void button2_Click(object sender, EventArgs e)
{
UpdateValues();
}
private void MyResonseHandler(object sender,
nsoftware.IPWorks.SnmpmgrResponseEventArgs e)
{
Val1 = System.Int64.Parse(MyVar.Value1);
Val2 = System.Int64.Parse(MyVar.Value2);
UpdateValues();
}
private void UpdateValues()
{
MessageBox.Show("Updating Values");
label1.Text = Convert.ToString(Val1);
label2.Text = Convert.ToString(Val2);
}
}
}
of programming (with, cough, Delphi). I'm writing a mobile app in C# with
Visual Studio 2005. I think there must be something fundamental that I'm
missing and could use a pointer in the right direction.
Below is a simplified version of a test program. I am using a namespace
provided from a dll file (used as MyNameSpace here). Anyway, I create a
component from within, which has a callback method. When I initiate the
process (button1_click), the callback happens just fine. However, I can not
seem to update any of the controls on the MainForm. As you will see, my
callback method has a call to Update Values. The call happens, but the
labels never get updated. However, initiating Button2_Click, will then call
UpdateValues and the labels will be updated.
It almost seems like my component is referencing a different instance of
MainForm. I would suspect this would be the behavior if I had not preceeded
my component with 'this' when creating it or the callback method. But, I
thought I got that right.
Anyway, anyone have an clues? Thanks for the help
Jim
============================================================
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MyNameSpace;
namespace MyTestApp
{
public partial class MainForm : Form
{
private MyClass MyVar;
public MainForm()
{
InitializeComponent();
Int Val1, Val2;
this.MyVar = new MyClass();
this.MyVar.OnResponse += new
MyClass.OnResponseHandler(this.MyResponseHandler);
}
private void button1_Click(object sender, EventArgs e)
{
MyVar.SendRequest();
}
private void button2_Click(object sender, EventArgs e)
{
UpdateValues();
}
private void MyResonseHandler(object sender,
nsoftware.IPWorks.SnmpmgrResponseEventArgs e)
{
Val1 = System.Int64.Parse(MyVar.Value1);
Val2 = System.Int64.Parse(MyVar.Value2);
UpdateValues();
}
private void UpdateValues()
{
MessageBox.Show("Updating Values");
label1.Text = Convert.ToString(Val1);
label2.Text = Convert.ToString(Val2);
}
}
}