I would like to update my UI through another class, I have tried doing this by creating a form1 object and using a method to update the textbox. This leads to an error which informs me that my device is not properly running.
So basically how do I update a textbox on my Form1 using my samplegrabber.cs class? This class is called constantly, however I only need to use the string .
The ISampleGrabber class calls the SampleCB method which consists of:
public int SampleCB(double sampletime, IMediaSample sample)
{
if (sample == null)
{
return -1;
}
try
{
int length = sample.GetActualDataLength();
IntPtr buffer;
if (sample.GetPointer(out buffer) == 0 && length > 0)
{
Bitmap bitmapOfFrame = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, buffer);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Marshal.ReleaseComObject(sample);
return 0;
}
The form1 object is created within the if statement, the erroroccurs even if I create the object (Even without the f1.updateTextBox(id);
) line.
The `updateTextBox1' is created in Form1:
public void updateTextBox1(string id)
{
textBox1.Text = id;
}
The error I receive is as follows:
COMException(0x8007001F)A device attached to the system is not functioning properly.