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. InvokeRequired

InvokeRequired

Scheduled Pinned Locked Moved C#
help
3 Posts 3 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.
  • M Offline
    M Offline
    MAW30
    wrote on last edited by
    #1

    I am trying to click a button programmatically. If I click the button with my mouse it works fine by going out to the internet and asking for info the website thens sends the info requested. However I have this on a timer (DelegateTimer, found here) When the timer sends the request to "ButtonUpdatesPerformClick()" the .PerformClick does not work below. I cannot bypass the button by going to "NonButtonUpdates()", because when it goes out to the internet, the information never comes back. Can anyone help me with this problem. Thanks in advance. Michael

    delegate void SetUpdatesCallback();

    public void ButtonUpdatesPerformClick()
    {
    if (this.buttonUpdates.InvokeRequired)
    {
    SetUpdatesCallback button = new SetUpdatesCallback(this.ButtonUpdatesPerformClick);
    this.Invoke(button, new object[] { });
    }
    else
    {
    this.buttonUpdates.PerformClick();
    }
    }
    private void buttonUpdates_Click(object sender, EventArgs e)
    {
    this.NonButtonUpdates();
    }
    private void NonButtonUpdates()
    {
    this.GoToWebsiteGetData();
    }

    S B 2 Replies Last reply
    0
    • M MAW30

      I am trying to click a button programmatically. If I click the button with my mouse it works fine by going out to the internet and asking for info the website thens sends the info requested. However I have this on a timer (DelegateTimer, found here) When the timer sends the request to "ButtonUpdatesPerformClick()" the .PerformClick does not work below. I cannot bypass the button by going to "NonButtonUpdates()", because when it goes out to the internet, the information never comes back. Can anyone help me with this problem. Thanks in advance. Michael

      delegate void SetUpdatesCallback();

      public void ButtonUpdatesPerformClick()
      {
      if (this.buttonUpdates.InvokeRequired)
      {
      SetUpdatesCallback button = new SetUpdatesCallback(this.ButtonUpdatesPerformClick);
      this.Invoke(button, new object[] { });
      }
      else
      {
      this.buttonUpdates.PerformClick();
      }
      }
      private void buttonUpdates_Click(object sender, EventArgs e)
      {
      this.NonButtonUpdates();
      }
      private void NonButtonUpdates()
      {
      this.GoToWebsiteGetData();
      }

      S Offline
      S Offline
      SledgeHammer01
      wrote on last edited by
      #2

      Your code makes zero sense. Have your click handler call a private method with no arguments DoStuff() for example. You don't want to click the button programatically, now do you? Do you actually want the button to press itself visually as if by magic? Probably not. You just want the code behind it to execute. So your timer or whatever would also just call the DoStuff() method directly.

      1 Reply Last reply
      0
      • M MAW30

        I am trying to click a button programmatically. If I click the button with my mouse it works fine by going out to the internet and asking for info the website thens sends the info requested. However I have this on a timer (DelegateTimer, found here) When the timer sends the request to "ButtonUpdatesPerformClick()" the .PerformClick does not work below. I cannot bypass the button by going to "NonButtonUpdates()", because when it goes out to the internet, the information never comes back. Can anyone help me with this problem. Thanks in advance. Michael

        delegate void SetUpdatesCallback();

        public void ButtonUpdatesPerformClick()
        {
        if (this.buttonUpdates.InvokeRequired)
        {
        SetUpdatesCallback button = new SetUpdatesCallback(this.ButtonUpdatesPerformClick);
        this.Invoke(button, new object[] { });
        }
        else
        {
        this.buttonUpdates.PerformClick();
        }
        }
        private void buttonUpdates_Click(object sender, EventArgs e)
        {
        this.NonButtonUpdates();
        }
        private void NonButtonUpdates()
        {
        this.GoToWebsiteGetData();
        }

        B Offline
        B Offline
        Braj_12
        wrote on last edited by
        #3

        You can call your click Event in simple method whenever you required.There is no need of button click.

        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