Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. threading, invoke

threading, invoke

Scheduled Pinned Locked Moved C#
questiondesignhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benjamin yap
    wrote on last edited by
    #1

    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'

    S 1 Reply Last reply
    0
    • B benjamin yap

      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'

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      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 }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups