Sara Code

Sara Code

  • NA
  • 10
  • 668

Newsletter windows application or windows service

Nov 4 2016 11:41 AM
  Hello all,
I want to make a newsletter software that runs on all the PCs once there is a news or update it will popup a form containing the updates
what i've acheived till now is
two form one is the main form that invoke the popup form, the sequence of my code is :
1- main from load the popup form and then hide it
2- press button to start the program and it will hide the main
3- at event of button click while(1) and check every minute if the SQL table has news inside it or not
4- if there is a news it will show the popup form for 1 minute after that it hide it
5- the continue running and repeats
what I am asking for is what is the knowledge that I need in order to reliable software
and instead of while(1) how to trigger the software to popup the form when there is anything in the SQL table ? and finally is there any similar open source software that do what I need or something alike?

here is my code:
public partial class Form1 : Form
{
ClassMasterData cMaster = new ClassMasterData();

       DataTable dtNewFeed;
       Form_Popup news;
       int always = 1;
       public Form1()
        {

            InitializeComponent();
            news = new Form_Popup();
            news.Show();
            news.Hide();

        }

    private void button1_Click(object sender, EventArgs e)
    {

        TimeSpan interval = new TimeSpan(0, 1, 0);
        this.Visible = false;
        while (always == 1)
        {
        System.Threading.Thread.Sleep(1 * 60 * 1000);
        dtNewFeed = cMaster.Select_DailyNews();
        if (dtNewFeed.Rows.Count != 0)

                      {

            news.Reformat(int.Parse(dtNewFeed.Rows[0]["nType"].ToString()), dtNewFeed.Rows[0]["strMessage"].ToString(), null);
            news.Show();
            news.Refresh();


                          //NativeMethods.BlockInput(interval);
                          System.Threading.Thread.Sleep(1 * 60 * 1000);
                           news.Hide();
                            news.Refresh();



                }




}

}

Answers (1)