Click here to Skip to main content
15,894,539 members
Home / Discussions / C#
   

C#

 
GeneralRe: Image upload error javascript/c# Pin
John Nederveen26-Feb-17 8:15
John Nederveen26-Feb-17 8:15 
GeneralRe: Image upload error javascript/c# Pin
Dave Kreskowiak26-Feb-17 8:30
mveDave Kreskowiak26-Feb-17 8:30 
GeneralRe: Image upload error javascript/c# Pin
John Nederveen26-Feb-17 9:05
John Nederveen26-Feb-17 9:05 
GeneralRe: Image upload error javascript/c# Pin
Dave Kreskowiak26-Feb-17 10:48
mveDave Kreskowiak26-Feb-17 10:48 
QuestionWMI Events can't get User | ManagementEventWatcher, __INstanceCreationEvent, Win32_Process GetOwner Pin
Member 1302224424-Feb-17 10:25
Member 1302224424-Feb-17 10:25 
AnswerRe: WMI Events can't get User | ManagementEventWatcher, __INstanceCreationEvent, Win32_Process GetOwner Pin
Michael_Davies24-Feb-17 10:37
Michael_Davies24-Feb-17 10:37 
GeneralRe: WMI Events can't get User | ManagementEventWatcher, __INstanceCreationEvent, Win32_Process GetOwner Pin
Member 1302224424-Feb-17 16:02
Member 1302224424-Feb-17 16:02 
QuestionHow to customize timer to fire my routine at specific time Pin
Tridip Bhattacharjee23-Feb-17 22:33
professionalTridip Bhattacharjee23-Feb-17 22:33 
i am using this code
C#
using System;
using System.Windows.Forms;
using System.Timers;

namespace T_TEST
{
    public partial class Form1 : Form
    {
        static System.Timers.Timer timer;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            schedule_Timer();
        }

        static void schedule_Timer()
        {
            Console.WriteLine("### Timer Started ###");

            DateTime nowTime = DateTime.Now;
            DateTime scheduledTime = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, 1, 59, 0, 0); //Specify your scheduled time HH,MM,SS [1am and 59 minutes]
            if (nowTime > scheduledTime)
            {
                scheduledTime = scheduledTime.AddDays(1);
            }

            double tickTime = (double)(scheduledTime - DateTime.Now).TotalMilliseconds;
            timer = new System.Timers.Timer(tickTime);
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }

        static void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            //Console.WriteLine("### Timer Stopped ### \n");
            timer.Stop();
            MessageBox.Show("Hello World!!!");
            //Console.WriteLine("### Scheduled Task Started ### \n\n");
            //Console.WriteLine("Hello World!!! - Performing scheduled task\n");
            //Console.WriteLine("### Task Finished ### \n\n");
            schedule_Timer();
        }
    }
}

the above code has one problem that once the timer fire then it will fire next day. i want if timer fire and after few minute if i reset my system time again then it should fire again.

how to customize the above code for my requirement. anyone mind to help me plzzz.

thanks
tbhattacharjee

AnswerRe: How to customize timer to fire my routine at specific time Pin
Pete O'Hanlon23-Feb-17 22:42
mvePete O'Hanlon23-Feb-17 22:42 
AnswerRe: How to customize timer to fire my routine at specific time Pin
OriginalGriff23-Feb-17 22:46
mveOriginalGriff23-Feb-17 22:46 
GeneralRe: How to customize timer to fire my routine at specific time Pin
Tridip Bhattacharjee23-Feb-17 22:50
professionalTridip Bhattacharjee23-Feb-17 22:50 
GeneralRe: How to customize timer to fire my routine at specific time Pin
OriginalGriff23-Feb-17 23:01
mveOriginalGriff23-Feb-17 23:01 
AnswerRe: How to customize timer to fire my routine at specific time Pin
Ralf Meier24-Feb-17 0:16
mveRalf Meier24-Feb-17 0:16 
QuestionInserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 8:16
Jammer23-Feb-17 8:16 
AnswerRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 9:53
mveGerry Schmitz23-Feb-17 9:53 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 10:16
Jammer23-Feb-17 10:16 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 11:35
mveGerry Schmitz23-Feb-17 11:35 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 13:04
Jammer23-Feb-17 13:04 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 13:36
mveGerry Schmitz23-Feb-17 13:36 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 13:45
Jammer23-Feb-17 13:45 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 13:54
mveGerry Schmitz23-Feb-17 13:54 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 20:34
Jammer23-Feb-17 20:34 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 20:38
mveGerry Schmitz23-Feb-17 20:38 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Jammer23-Feb-17 20:49
Jammer23-Feb-17 20:49 
GeneralRe: Inserting Localised Lookup Data into a Fresh Database Pin
Gerry Schmitz23-Feb-17 21:28
mveGerry Schmitz23-Feb-17 21:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.