i wrote extension class, for textbox control.
public static class Extensions { public static void AddMessage(this System.Windows.Forms.TextBox textbox,string message){ textbox.AppendText(DateTime.Now.ToString() + " " + message + "\r\n"); } } my textbox control, passed to the "Core" class via constructor, from form, like:
public static TextBox text; public Core(TextBox text) { Core.text = text; } and here is event:
...{ change.DataChanged += new Opc.Da.DataChangedEventHandler(OnDataChange); }... callback:
public void OnDataChange(object subscriptionHandle, object requestHandle, Opc.Da.ItemValueResult[] values) { Send(values,configuration.service.adress); } public static void Send(Opc.Da.ItemValueResult[] values,string addr) { text.AddMessage("test"); //here comes exception } and at the text.AddMessage(...) i have: "Microsoft.VisualStudio.Debugger.Runtime.CrossThreadMessagingException"
EDIT: i think my problem not in function Add.Message, cause textbox coming to extension already with exception, what im misssing? so i think i even can not call "text" from "Send" function
EDIT: exception for "text" comming from
change.DataChanged += new Opc.Da.DataChangedEventHandler(OnDataChange);