# Load form from signal change

**URL:** <https://tech-community.robotics.abb.com/t/load-form-from-signal-change/2419>\
**Category:** Developer Tools\
**Created:** [January 12, 2009, 11:54pm UTC](https://tech-community.robotics.abb.com/t/load-form-from-signal-change/2419 "2009-01-12T23:54:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![51Magnum](https://avatars.discourse-cdn.com/v4/letter/5/e36b37/32.png) [@51Magnum](https://tech-community.robotics.abb.com/u/51Magnum)\
**Post date:** [January 12, 2009, 11:54pm UTC](https://tech-community.robotics.abb.com/t/load-form-from-signal-change/2419/1 "2009-01-12T23:54:49Z")

</div>

I am getting frustrated. I need to load a new form when a signal changes in the IRC5. I can not use the SignalBindingSource because I have to bind a visible control to it in order to see it change. And I can not get the standard signals to show my form. Here is a code example.

private void \_sigSystemState\_Changed(object sender, ABB.Robotics.Controllers.IOSystemDomain.SignalChangedEventArgs e)

//Update the GUI if the signal GI\_001 changes in the controller

{

CalibrationView2 \_CalibrationView2 = new CalibrationView2();

\_CalibrationView2.ShowMe(this);

}

private void button1\_Click(object sender, EventArgs e)

{

CalibrationView2 \_CalibrationView2 = new CalibrationView2();

\_CalibrationView2.ShowMe(this);

}

The button example works fine but the SignalBindingSouces change event is on another thread? Exact error: “Controls created on one thread cannot be parented to a control on a different thread.”

So how do I have a simple signal show a new view/form?

Shane

---

<div class="post-metadata">

**Author:** ![carlosmtz2000](https://avatars.discourse-cdn.com/v4/letter/c/e79b87/32.png) [@carlosmtz2000](https://tech-community.robotics.abb.com/u/carlosmtz2000)\
**Post date:** [January 13, 2009, 4:52am UTC](https://tech-community.robotics.abb.com/t/load-form-from-signal-change/2419/2 "2009-01-13T04:52:38Z")

</div>

Hi Shane,

I tend to over-explained the stuff … please let me know if I am goind to much in detail, I will do my best in next posts :). So here it comes

Only the UI threads are allow to execute code that will modify the user interface.

Inside a Teach Pendant application, there is only one UI thread running at all time. All the events coming for the IRC5 (either by the BindingSource or a Changed event of a RapidData or Signal) comes in a different thread. Hence, what we need to do is to call the UI thread from your executing thread. Here it comes some sample code:

void MySignal\_Changed(object sender, SignalChangedEventArgs e)

{

// We are running in a non-ui thread, so it is not allowed to make changes in the user interface. Lets invoke the UI thread

// In order to invoke the UI thread, we need to use a control that was created in the UI thread.

// In most of the cases, the form in which you are runnning was created in the UI tread, so lets use that one.

// We will assume that ‘this’ makes reference to the form

this.Invoke(new SignalChangedEventHandler(MySignal\_Changed\_UI), sender, e);

}

void MySignal\_Changed\_UI(object sender, SignalChangedEventArgs e)

{

// This code will be running in the UI thread as long as it comes from an invoke

// Here, you can open your view

CalibrationView2 \_CalibrationView2 = new CalibrationView2();

\_CalibrationView2.ShowMe(this);

}

In your case, the method \_CalibrationView2.ShowMe(this) is tryting to create and display a Form. It does not work in the method “\_sigSystemState\_Changed” because this in called by the SignalBindingSource; the other one because a method that is called for a Click event, it is executed inside a UI thread already (the event is UI driven as such).  
Hope this helps to explain the behaviour.

Saludos … Carlos

---

<div class="post-metadata">

**Author:** ![51Magnum](https://avatars.discourse-cdn.com/v4/letter/5/e36b37/32.png) [@51Magnum](https://tech-community.robotics.abb.com/u/51Magnum)\
**Post date:** [January 13, 2009, 2:14pm UTC](https://tech-community.robotics.abb.com/t/load-form-from-signal-change/2419/3 "2009-01-13T14:14:37Z")

</div>

Carlos,

That is exactly what I needed! Thanks for taking the time and effort to, as in your words, over-explain stuff. It really is appreciated.

I will try this this morning,  
Shane
