cancel
Showing results for 
Search instead for 
Did you mean: 

How to identify when B1 disconnects the addon

leandro_daminelli2
Participant
0 Kudos
116

Hello everyone.

When I throw an exception inside an event, B1 disconnects the add-on. Is there any way to find out that this happened?

I did some tests and even when the addon got disconnected I still can send messages via MessageBox for example. The only difference that I saw is that B1 does not send events anymore.

I need to know when this happens because the application will still run after being disconnected, so I need to kill the task to avoid many executables running for nothing.

Thank you in advice.

View Entire Topic
leandro_daminelli2
Participant
0 Kudos

Solved the problem with the following code:


Task.Factory.StartNew(() =>

            {

                while (true)

                {

                    try

                    {

                        var lActiveForm = Connection.Forms.ActiveForm;

                      //Disconnect form is type 0

                        if (lActiveForm.TypeEx == "0")

                        {

                            //Item 1 is the static text which shows the description of the disconnected addon

                            if (((StaticText)lActiveForm.Items.Item("1").Specific).Caption.Contains("MyAddOnName"))

                              System.Windows.Forms.Application.Exit();                           

                        }

                    }

                    catch { }

                    Thread.Sleep(1000);

                }

            });

edy_simon
Active Contributor
0 Kudos

Hi Leandro,

Good idea, not ideal but it should do the trick.

I have been wondering the same my self, thanks for posting this.

But, do note that many system messages come through this form type '0'.

Maybe need to check more exact wording on the static text, to make sure it is indeed the disconnect message.

Regards

Edy