Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I developed a logger for data gathering from external device. it should record some data (int x6, string x4) once per second and supposed to run 24x7. for the first 24 hours everything is fine but then it hang over and the only thing that i can do is to restart whole system.

is there any method to get rid of variables at the end of each cycle?

Thanks
Posted

1 solution

Hi,
First of all you should not declare int x6, string x4 separate variables instead you should create a class including all the required attributes as properties and then create the object of the class inside logical piece of code
if you are using c# code behind the best way is to put your logical piece of code inside Using clause. secondly you can implement the Idisposable interface in the class where you have return the logic
example given below
you variables as class

C#
public class clsEmail
   {
       public string EmailFrom
       {
           get { return _EmailFrom; }
           set { _EmailFrom = value; }
       }
       public string EmailTo
       {
           get { return _emailTo; }
           set { _emailTo = value; }
       }
       public string Emailcc
       {
           get { return _emailcc; }
           set { _emailcc = value; }
       }
       public string EmailSub
       {
           get { return _EmailSub; }
           set { _EmailSub = value; }
       }
       public string Emailbody
       {
           get { return _Emailbody; }
           set { _Emailbody = value; }
       }

}

C#
using (someEntities objDataContext = new someEntities())
                {
clsEmail obj=new clsEmail();
class1 objclass=new Class1
                    inboxId = (from inbox in objTWEYPSDataContext.tblInboxItems
                               where inbox.RequestId == RequestId && inbox.StartedBy == startedBy && inbox.State == actionState
                               select inbox.InboxId).SingleOrDefault();

                    return inboxId;
                }



Once you come out of the above logical code all the objects like objDataContext, objclass and obj/pre> etc will be destroyed



Thanks and regards
Murtuza
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900