threading, invoke
-
Hi, I got this chart object on my UI thread called 'm_ChartControl' I got a method called AddAnnotations that will be run on a new thread in my Form_Load method. Inside my AddAnnotation method there is a line of code that do this. Annotation a = m_ChartControl.Charts[0].AnnotationList.CreateAnnotation(); But m_ChartControl.Charts[0].AnnotationList.CreateAnnotation(); is in the UI thread. How do i create a delegate to put it here? I have tried this.
private delegate Annotation AddAnnotation(); AddAnnotation addNewAnnotation; private Annotation CreateAnnotation() { return m\_ChartControl.Charts\[0\].AnnotationList.CreateAnnotation(); } void cAnnotation() { this.Invoke(addNewAnnotation); }
I changed this to Annotation a = cAnnotation(); and i get this error Error 18 Cannot implicitly convert type 'void' to 'Manco.Chart.CF.Layout.Annotation'
-
Hi, I got this chart object on my UI thread called 'm_ChartControl' I got a method called AddAnnotations that will be run on a new thread in my Form_Load method. Inside my AddAnnotation method there is a line of code that do this. Annotation a = m_ChartControl.Charts[0].AnnotationList.CreateAnnotation(); But m_ChartControl.Charts[0].AnnotationList.CreateAnnotation(); is in the UI thread. How do i create a delegate to put it here? I have tried this.
private delegate Annotation AddAnnotation(); AddAnnotation addNewAnnotation; private Annotation CreateAnnotation() { return m\_ChartControl.Charts\[0\].AnnotationList.CreateAnnotation(); } void cAnnotation() { this.Invoke(addNewAnnotation); }
I changed this to Annotation a = cAnnotation(); and i get this error Error 18 Cannot implicitly convert type 'void' to 'Manco.Chart.CF.Layout.Annotation'
Threading in .NET and WinForms[^] void cAnnotation() { AddAnnotation del = new AddAnnotation(); this.Invoke(del); } public Annotation() { //This function will be referenced and executed on destination form/control }