Advertisement

05.07.2008 at 09:35AM PDT, ID: 23383407
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

C# Timer
Tags: Microsoft, C#
Hi Guys n gals,

I have the following C# application that I plan to use to read an XML file every 20 minutes and then add the results into a MySql database.

This all works fine, my problem is that I have a strip status label which I want to change the text of depending on where the script is currently, so for example when the timer tick event is fired it says "working.." and then when the connection to the database is established it says "connected" etc etc.

This however does not work, the label is not changed until the rest of the tick event has finished.
From reading around I understand I could get over this by using threads ?

Is this correct and could someone help me change my code to reflect this ?
Or if you could give me some ideas on how I can achieve my goal.

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Xml;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using MySql.Data.MySqlClient;
 
// direct news namespace
namespace DirectNews
{
    public partial class Form1 : Form
    {
         // replaces '' with ' and ' with'' so text gets inserted without any sql errors
         private string EncodeIt(string TextString)  
         {
             // return the formatted string
             return TextString.Replace("'", "''");
         }
 
        // form 1
        public Form1()
        {
            // initialize
            InitializeComponent();
        }
 
        // on load
        private void Form1_Load(object sender, EventArgs e)
        {
            // run the timer
            timer1.Enabled = true;
        }
 
        // for each timer click
        private void timer1_Tick(object sender, EventArgs e)
        {
            // update all articles
            GetArticles();
        }
        
        // run the timer
        private void GetArticles()
        {
            // file location and name
            FileStream fs = new FileStream(@"c:/temp/directnews/log/" + DateTime.Now.ToLongDateString() + ".txt", FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter m_streamWriter = new StreamWriter(fs);
 
            // update label
            toolStripStatusLabel1.Text = "Working...";
 
            // write the first line of text, logged at etc
            m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
            m_streamWriter.WriteLine(" \n");
            m_streamWriter.WriteLine("===================================== \n");
            m_streamWriter.Write("DirectNews Article Log: ");
            m_streamWriter.WriteLine("{0} {1}", DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString());
            m_streamWriter.WriteLine("===================================== \n");
            m_streamWriter.Flush();
 
            // try
            try
            {
                // variables
                string articleID;
                string Heading;
                string LongHeading;
                string articledate;
                string content;
                string summary;
                string ImgURL;
                string ImgWidth;
                string ImgHeight;
                string ImgRatio;
                string PhotoTag;
 
                // connecting
                toolStripStatusLabel1.Text = "Connecting to the database..";
 
                // connection to the database
                MySqlConnection dbcon = new MySqlConnection("SQL CON;");
                dbcon.Open();
 
                // connected
                toolStripStatusLabel1.Text = "Connected";
 
                // link to the reader, load the reader
                XmlTextReader xtr = new XmlTextReader("http://feeds.directnews.org.uk/?c21c0905-b9ca-43ee-87be-7e4308406da6");
                xtr.WhitespaceHandling = WhitespaceHandling.None;
                XmlDocument X = new XmlDocument();
                X.Load(xtr);
 
                // reading xml
                toolStripStatusLabel1.Text = "Reading XML ..";
 
                // check value found
                if (X != null)
                {
                    // select the article node
                    XmlNodeList ArticleList = X.SelectNodes("InfoStreamResults/Article");
 
                    // for each article
                    foreach (XmlNode Article in ArticleList)
                    {
                        // empty variables
                        Heading = "";
                        LongHeading = "";
                        articledate = "";
                        articleID = "";
                        content = "";
                        summary = "";
                        ImgURL = "";
                        PhotoTag = "";
                        ImgWidth = "";
                        ImgRatio = "";
                        ImgHeight = "";
 
                        // get article value
                        articleID = Article.SelectSingleNode("@ID").Value;
 
                        // check for heading
                        if (Article.SelectSingleNode("Heading") != null)
                        {
                            // encode the header
                            Heading = EncodeIt(Article.SelectSingleNode("Heading").InnerText);
                        }
 
                        // check for long heading
                        if (Article.SelectSingleNode("LongHeading") != null)
                        {
                            // encode the header
                            LongHeading = EncodeIt(Article.SelectSingleNode("LongHeading").InnerText);
                        }
 
                        // check for date
                        if (Article.SelectSingleNode("Date") != null)
                        {
                            // check for created date
                            if (Article.SelectSingleNode("@Created") != null)
                            {
                                // build the article date
                                articledate = Article.SelectSingleNode("Date").InnerText + " " + Article.SelectSingleNode("@Created").Value;
                            }
 
                            // else created date
                            else
                            {
                                // build the article date
                                articledate = Article.SelectSingleNode("Date").InnerText;
                            }
                        }
 
                        // check for Contents
                        if (Article.SelectSingleNode("Contents") != null)
                        {
                            // encode the Contents
                            content = EncodeIt(Article.SelectSingleNode("Contents").InnerText);
                        }
 
                        // check for long Summary
                        if (Article.SelectSingleNode("Summary") != null)
                        {
                            // encode the Summary
                            summary = EncodeIt(Article.SelectSingleNode("Summary").InnerText);
                        }
 
                        // check for image url
                        if (Article.SelectSingleNode("Picture/Large/URL") != null)
                        {
                            // encode the image url
                            ImgURL = EncodeIt(Article.SelectSingleNode("Picture/Large/URL").InnerText);
                        }
 
                        // check for image width
                        if (Article.SelectSingleNode("Picture/Large/@Width") != null)
                        {
                            // set the image width
                            ImgWidth = Article.SelectSingleNode("Picture/Large/@Width").Value;
                        }
 
                        // check for img ratio
                        if (Article.SelectSingleNode("Picture/@Ratio") != null)
                        {
                            // img ratio
                            ImgRatio = Article.SelectSingleNode("Picture/@Ratio").Value;
                        }
 
                        // check for image height
                        if (Article.SelectSingleNode("Picture/Large/@Height") != null)
                        {
                            // image height
                            ImgHeight = Article.SelectSingleNode("Picture/Large/@Height").Value;
                        }
 
                        // check for photo tag
                        if (Article.SelectSingleNode("Picture/@PhotoTag") != null)
                        {
                            // encode the photo tag
                            PhotoTag = EncodeIt(Article.SelectSingleNode("Picture/@PhotoTag").Value);
                        }
 
                        // variables
                        string sqlquery;
                        MySqlCommand checkItemExist, deleteCategory, addCategory;
                        MySqlCommand InsertUpdateCommand;
 
                        // sql statement to delete the cats
                        sqlquery = "Delete from Categories where ArticleID ='" + articleID + "'";
                        deleteCategory = new MySqlCommand(sqlquery, dbcon);
                        deleteCategory.ExecuteNonQuery();
 
                        // delete old cats
                        toolStripStatusLabel1.Text = "Deleting old categories";
 
                        // the category
                        XmlNodeList CatNodesList = Article.SelectNodes("Categories/Category");
 
                        // for each category
                        foreach (XmlNode category in CatNodesList)
                        {
                            // add new cat query
                            sqlquery = "Insert INTO Categories (ArticleID, CategoryID, CategoryName) Values ('" + articleID + "' ,'" + category.SelectSingleNode("@ID").Value + "', '" + EncodeIt(category.InnerText) + "')";
                            addCategory = new MySqlCommand(sqlquery, dbcon);
                            addCategory.ExecuteNonQuery();
                        }
 
                        // add cats
                        toolStripStatusLabel1.Text = "add updated categories";
 
                        // select query
                        sqlquery = "Select ArticleID from FeedData where ArticleID='" + articleID + "'";
                        checkItemExist = new MySqlCommand(sqlquery, dbcon);
                        checkItemExist.ExecuteNonQuery();
 
                        // check if article already exists
                        toolStripStatusLabel1.Text = "checking for article";
 
                        // reader
                        MySqlDataReader dr = checkItemExist.ExecuteReader();
                        Boolean ItemAlreadyExists = dr.HasRows;
                        dr.Close();
 
                        // item found
                        if (ItemAlreadyExists == true)
                        {
                            // update the article in the database
                            sqlquery = "Update FeedData SET Heading ='" + Heading + "', Date ='" + articledate + "', Content = '" + content + "', LongHeading ='" + LongHeading + "', Summary ='" + summary + "', ImgURL ='" + ImgURL + "', ImgWidth ='" + ImgWidth + "', ImgHeight ='" + ImgHeight + "', ImgRatio ='" + ImgRatio + "', PhotoTag ='" + PhotoTag + "' WHERE ArticleID = '" + articleID + "'";
                            InsertUpdateCommand = new MySqlCommand(sqlquery, dbcon);
                            m_streamWriter.WriteLine("Article ID updated: " + articleID + " @ " + DateTime.Now.ToLongTimeString());
                            m_streamWriter.Flush();
 
                            // update article
                            toolStripStatusLabel1.Text = "article found, updating it";
                        }
 
                        // item not found
                        else
                        {
                            // insert new article
                            sqlquery = "Insert INTO FeedData (ArticleID, Heading, Content, Date, LongHeading, Summary, ImgURL, ImgHeight, ImgWidth, ImgRatio, PhotoTag) Values ('" + articleID + "' ,'" + Heading + "', '" + content + "', '" + articledate + "', '" + LongHeading + "', '" + summary + "', '" + ImgURL + "', '" + ImgHeight + "', '" + ImgWidth + "', '" + ImgRatio + "', '" + PhotoTag + "')";
                            InsertUpdateCommand = new MySqlCommand(sqlquery, dbcon);
                            m_streamWriter.WriteLine("Article ID added: " + articleID + " @ " + DateTime.Now.ToLongTimeString());
                            m_streamWriter.Flush();
 
                            toolStripStatusLabel1.Text = "article not found, adding it";
                        }
 
                        // execute
                        InsertUpdateCommand.ExecuteNonQuery();
 
                        // update the label
                        label3.Text = DateTime.Now.ToString();
                    }
                }
 
                // flush the connection
                dbcon.Close();
 
                // update label
                toolStripStatusLabel1.Text = "Ready";
                timer1.Interval = 1200000;
 
                // close
                fs.Close();
                m_streamWriter.Close();
            }
 
            // catch exception
            catch (Exception ex)
            {
 
            }
        }
 
        // view log
        private void viewLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // open with notepad
            System.Diagnostics.Process.Start("notepad.exe", "c:/temp/directnews/log/" + DateTime.Now.ToLongDateString() + ".txt");
        }
 
        // force sync
        private void forceSyncToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timer1.Interval = 1000;
            toolStripStatusLabel1.Text = "Working...";
        }
 
        // close the program
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
 
    }
}
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: TheJay04
Solution Provided By: Idle_Mind
Participating Experts: 2
Solution Grade: A
Views: 27
Translate:
Loading Advertisement...
05.07.2008 at 09:47AM PDT, ID: 21518199

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 11:02AM PDT, ID: 21518852

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 01:42PM PDT, ID: 21520200

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.07.2008 at 03:23PM PDT, ID: 21520877

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 01:07AM PDT, ID: 21523058

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 07:13AM PDT, ID: 21524865

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.08.2008 at 07:35AM PDT, ID: 21525090

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.07.2008 at 09:47AM PDT, ID: 21518199
I assume that even forcing a refresh will not help.  The problem is that you are changing the label in the same thread as the one which is intensively reading the XML file.  The intensive loop is delaying the task of refreshing the label.  The best alternative is that when your timer fires, you start a working thread and do the reading and DB update in that thread.  Then send a signal to the main program thread to change the label.  You can send sucha  signal by posting a message to the main window of your program (I assume it has one).  You also have to do a little synchronization between the threads, especially if you want to stop the process on some external signal.  If it sounds a whole lot of work for a little something, it is.  But again, that is what makes a program to stand out.
 
05.07.2008 at 11:02AM PDT, ID: 21518852

Rank: Sage

Whenever (every time!) you update the label, make a call to DoEvents():

    toolStripStatusLabel1.Text = "checking for article";
    Application.DoEvents();

If you don't want to have to do this then move your code to seperate thread.  For C# 2005 (or above), the BackgroundWorker control makes this pretty easy.
 
05.07.2008 at 01:42PM PDT, ID: 21520200
Thanks Idle_Mind,

Using the code you mentioned it worked fine, can you please explain what this does and the implications in using it.  Is it better to use this method or use a seperate thread ?
 
05.07.2008 at 03:23PM PDT, ID: 21520877

Rank: Sage

Basically you are "tying up" the main UI thread by executing processor intensive code in the form.  When you update the label it "invalidates" it causing a WM_PAINT message to be sent to it so it can repaint itself.  BUT the code is still "STUCK" doing the code you told it to execute.  Normally the label would update only after the current sub is finished executing.  If this is a long process then the delay is quite noticeable.  The call to DoEvents() tells the main UI thread to check its message queue and to process whatever is there.  This allows things such as user interaction and paint messages to be processed before continuing with other code resulting in a "more responsive" UI.

Which is better?...it really depends on the code situation and programmers preference/ability.
 
05.08.2008 at 01:07AM PDT, ID: 21523058
Thanks for the great explanation.

Only one problem, now that I have added the doEvents trigger it keeps giving me an exception saying the text file I am writing to is already in use. Would this be caused by the doEvents ? and is there a possible fix you can think of ?

Thanks again
 
05.08.2008 at 07:13AM PDT, ID: 21524865

Rank: Sage

You are now experiencing a problem known as "re-entrant code".  Without DoEvents(), even the Timer "ticks" would get queued up and will execute synchronously...one after the other without any overlap.  Now that you have DoEvents() in place, it is possible to have more than one "tick" event code block trying to run at the same time.  This occus when the code in the Tick() event takes longer to execute than the Timer Interval().  To prevent this type of problem you can do several things:

(1) Increase Interval Time (not the best or safest approach)
(2) Use some sort of "locking" mechanism, such as Mutexes etc. (overly complicated for this scenario)
(3) Turn off the Timer at the top of the Tick() event then Turn it back on at the bottom:

        // for each timer click
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;

            // update all articles
            GetArticles();

            timer1.Enabled = true;
        }
Accepted Solution
 
05.08.2008 at 07:35AM PDT, ID: 21525090
Thank-you so much !

Everything is now working great and I have learnt so much.
Thanks again for your time.
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628