Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:32:51+00:00 2026-06-11T04:32:51+00:00

I am writing a small application for reminders. For this, I got great help

  • 0

I am writing a small application for reminders. For this, I got great help from a similar question and answer on Stack Overflow. I used the code mentioned by Thunder from here.

The relevant code is:

private void Form1_Load(object sender, EventArgs e)
    {
        System.Threading.TimerCallback callback = new            System.Threading.TimerCallback(ProcessTimerEvent);
        var dt =    new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day   , 10, 0, 0);

        if (DateTime.Now < dt)
        {
            var timer = new System.Threading.Timer(callback, null, dt - DateTime.Now, TimeSpan.FromHours(24));
        this.Hide(); // This line works... Form hides itself
        }

    }

    private void ProcessTimerEvent(object obj)
    {
        //MessageBox.Show("Hi Its Time");
        this.Show();  //This line does not work. Form gets disposed off instead of show
    }

My problem: I get everything as mentioned in that answer (including MessageBox). However, if I try to hide the form when a callback is made and show it once again instead of MessageBox.Show("Hi Its Time") it does not work. See my comments on each line. I don’t understand why the form gets disposed.

this.Visible() // does not work and disposed off the same way

Also tried to move the form out of screen by changing its location property. On return, bring back to its original location but this also does not work. What can I do to hide & show the form on return ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:32:53+00:00Added an answer on June 11, 2026 at 4:32 am

    I believe you’re having a cross thread issue. Your callback should look like this:

    private void ProcessTimerEvent(object obj)
    {
        if (this.InvokeRequired)
        {
            this.Invoke(new Action<object>(this.ProcessTimerEvent), obj);
        }
        else
        {
             this.Show();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am writing one small application to parse from XML to JSON object for iphone.
I am writing a small application to help people join an OpenVPN network. What
I'm writing a small application that aims to scrape XML from multiple sites and
I'm writing a small application which updates my AD with info from a DB
I've been given the task of writing a small application to help migrate over
I am writing small application in python which read records from Oracle and insert
I'm writing small application using OpenCV. Everything works great on my computer. I can
I am writing a small diagram drawing application (similar to Graphviz in spirit), and
I'm writing a small application which works at compiling a file from a source
I'm writing a small application in C# (.NET 4.0). I want to fire an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.