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

  • SEARCH
  • Home
  • 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 317943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:31:27+00:00 2026-05-12T08:31:27+00:00

I have a netbook with 1.20Ghz Processor & 1GB Ram. I’m running a C#

  • 0

I have a netbook with 1.20Ghz Processor & 1GB Ram.

I’m running a C# WinForms app on it which, at 5 minute intervals, reads every line of a text file and depending on what the content of that line is, either skips it or writes it to an xml file. Sometimes it may be processing about 2000 lines.

When it begins this task, the processor gets maxed out, 100% use. However on my desktop with 2.40Ghz Processor and 3GB Ram it’s untouched (for obvious reasons)… is there any way I can actually reduce this processor issue dramatically? The code isn’t complex, I’m not bad at coding either and I’m not constantly opening the file, reading and writing… it’s all done in one fell swoop.

Any help greatly appreciated!?

Sample Code

***Timer…..

#region Timers Setup

            aTimer.Tick += new EventHandler(OnTimedEvent);
            aTimer.Interval = 60000;
            aTimer.Enabled = true;
            aTimer.Start();
            radioButton60Mins.Checked = true;

            #endregion Timers Setup


private void OnTimedEvent(object source, EventArgs e)
        {
            string msgLoggerMessage = "Checking For New Messages " + DateTime.Now;
            listBoxActivityLog.Items.Add(msgLoggerMessage);
            MessageLogger messageLogger = new MessageLogger();
            messageLogger.LogMessage(msgLoggerMessage);

            if (radioButton1Min.Checked)
            {
                aTimer.Interval = 60000;
            }
            if (radioButton60Mins.Checked)
            {
                aTimer.Interval = 3600000;
            }
            if (radioButton5Mins.Checked)
            {
                aTimer.Interval = 300000;
            }

            // split the file into a list of sms messages
            List<SmsMessage> messages = smsPar.ParseFile(smsPar.CopyFile());

            // sanitize the list to get rid of stuff we don't want
            smsPar.SanitizeSmsMessageList(messages);

            ApplyAppropriateColoursToRecSMSListinDGV();
        }

public List<SmsMessage> ParseFile(string filePath)
        {
            List<SmsMessage> list = new List<SmsMessage>();
            using (StreamReader file = new StreamReader(filePath))
            {
                string line;
                while ((line = file.ReadLine()) != null)
                {
                    var sms = ParseLine(line);
                    list.Add(sms);
                }
            }
            return list;
        }

        public SmsMessage ParseLine(string line)
        {
            string[] words = line.Split(',');

            for (int i = 0; i < words.Length; i++)
            {

                words[i] = words[i].Trim('"');
            }
            SmsMessage msg = new SmsMessage();
            msg.Number = int.Parse(words[0]);
            msg.MobNumber = words[1];
            msg.Message = words[4];
            msg.FollowedUp = "Unassigned";
            msg.Outcome = string.Empty;

            try
            {

                //DateTime Conversion!!!
                string[] splitWords = words[2].Split('/');
                string year = splitWords[0].Replace("09", "20" + splitWords[0]);
                string dateString = splitWords[2] + "/" + splitWords[1] + "/" + year;
                string timeString = words[3];
                string wholeDT = dateString + " " + timeString;
                DateTime dateTime = DateTime.Parse(wholeDT);
                msg.Date = dateTime;

            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                Application.Exit();
            }
            return msg;
        }

        public void SanitizeSmsMessageList(List<SmsMessage> list)
        {
            // strip out unwanted messages
            // list.Remove(some_message); etc...
            List<SmsMessage> remove = new List<SmsMessage>();
            foreach (SmsMessage message in list)
            {
                if (message.Number > 1)
                {
                    remove.Add(message);
                }
            }
            foreach (SmsMessage msg in remove)
            {
                list.Remove(msg);
            }
            //Fire Received messages to xml doc
            ParseSmsToXMLDB(list);
}

public void ParseSmsToXMLDB(List<SmsMessage> list)
        {
            try
            {
                if (File.Exists(WriteDirectory + SaveName))
                {
                    xmlE.AddXMLElement(list, WriteDirectory + SaveName);
                }
                else
                {
                    xmlE.CreateNewXML(WriteDirectory + SaveName);
                    xmlE.AddXMLElement(list, WriteDirectory + SaveName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                Application.Exit();
            }
        }

public void CreateNewXML(string writeDir)
        {
            try
            {
                XElement Database = new XElement("Database");
                Database.Save(writeDir);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }

        public void AddXMLElement(List<SmsMessage> messages, string writeDir)
        {
            try
            {
                XElement Database = XElement.Load(writeDir);
                foreach (SmsMessage msg in messages)
                {
                    if (!DoesExist(msg.MobNumber, writeDir))
                    {
                        Database.Add(new XElement("SMS",
                              new XElement("Number", msg.MobNumber),
                              new XElement("DateTime", msg.Date),
                              new XElement("Message", msg.Message),
                              new XElement("FollowedUpBy", msg.FollowedUp),
                              new XElement("Outcome", msg.Outcome),
                        new XElement("Quantity", msg.Quantity),
                        new XElement("Points", msg.Points)));

                        EventNotify.SendNotification("A New Message Has Arrived!", msg.MobNumber);

                    }
                }
                Database.Save(writeDir);
                EventNotify.UpdateDataGridView();
                EventNotify.UpdateStatisticsDB();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }

public bool DoesExist(string number, string writeDir)
        {
            XElement main = XElement.Load(writeDir);
            return main.Descendants("Number")
                      .Any(element => element.Value == number);
        }
  • 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-05-12T08:31:27+00:00Added an answer on May 12, 2026 at 8:31 am

    Use a profiler and/or Performance Monitor and/or \\live.sysinternals.com\tools\procmon.exe and/or ResourceMonitor to determine what’s going on

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have just started using Visual Studio Professional's built-in unit testing features, which as I
I've just been setting up a new 10 netbook and have just installed Eclipse
I am making a portfolio website and have a horizontal slider which will slide
There's an app that I use on an XP netbook for tuning a car.
I've just upgraded to Ubuntu 11.04 on my Asus EeePC netbook, and have a
I bought a very weak netbook that comes preinstalled with android 2.0 which I
i have been debating which OS to use for a car pc.. and ubuntu
So I have done Gem install newgem (running under rvm) and also sudo gem
I have a paged WPF(.Net4) application which is too big for the screen when
Have just started using Google Chrome , and noticed in parts of our site,

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.