Click here to Skip to main content
15,892,517 members
Home / Discussions / C#
   

C#

 
GeneralRe: Rebooting to safe mode... Pin
Rose WiFiTech & Electronics Library Research Cen26-Oct-11 5:36
Rose WiFiTech & Electronics Library Research Cen26-Oct-11 5:36 
Questionc# Webbrowser control with frames Pin
Franklin Smith30-Nov-10 2:03
Franklin Smith30-Nov-10 2:03 
AnswerRe: c# Webbrowser control with frames Pin
Henry Minute30-Nov-10 4:09
Henry Minute30-Nov-10 4:09 
GeneralRe: c# Webbrowser control with frames Pin
Franklin Smith30-Nov-10 13:07
Franklin Smith30-Nov-10 13:07 
QuestionC# debug in vs2010 Pin
polycom12330-Nov-10 1:59
polycom12330-Nov-10 1:59 
AnswerRe: C# debug in vs2010 Pin
Luc Pattyn30-Nov-10 3:03
sitebuilderLuc Pattyn30-Nov-10 3:03 
GeneralRe: C# debug in vs2010 Pin
polycom12330-Nov-10 18:39
polycom12330-Nov-10 18:39 
QuestionCSV file logging data on timer event Pin
cages29-Nov-10 10:26
cages29-Nov-10 10:26 
I am logging data from a USB device (pooling the device) using a timer component with C#.
Every 250ms (timer tick) I read the data from the device and save it to a CSV (coma separated value) file.
I just thought I should ask if there is anyway to improve on the saving of the file. I am new to C#/.net so would really like a review of the idea.

1. Every timer tick I read two values from an object (the USB device interface).

2. Open the file by creating a Steame writer object;
StreamWrite out = new StreamWriter(filename, true).

3.Write the values to the file
out.Writeline("{0},{1}",value1,value2);

4.Close the file.
out.close();

The main question is should I keep opening and closing the file every tick or should I open it when the logging starts and close it when the user stops the logging of the data? The reason I close the file is so if the application fails I do not lose any data.( the file is being used only by this application).
Any comments to improve the code will be useful.

Thanks cages
QuestionRe: CSV file logging data on timer event Pin
Luc Pattyn29-Nov-10 10:28
sitebuilderLuc Pattyn29-Nov-10 10:28 
AnswerRe: CSV file logging data on timer event Pin
cages29-Nov-10 10:37
cages29-Nov-10 10:37 
AnswerRe: CSV file logging data on timer event Pin
Luc Pattyn29-Nov-10 10:47
sitebuilderLuc Pattyn29-Nov-10 10:47 
AnswerRe: CSV file logging data on timer event Pin
PIEBALDconsult29-Nov-10 11:08
mvePIEBALDconsult29-Nov-10 11:08 
AnswerRe: CSV file logging data on timer event Pin
Pete O'Hanlon29-Nov-10 11:13
mvePete O'Hanlon29-Nov-10 11:13 
QuestionPrinting from a C# application Pin
memorexr29-Nov-10 8:58
memorexr29-Nov-10 8:58 
AnswerRe: Printing from a C# application Pin
Henry Minute29-Nov-10 10:32
Henry Minute29-Nov-10 10:32 
GeneralRe: Printing from a C# application Pin
Luc Pattyn29-Nov-10 11:09
sitebuilderLuc Pattyn29-Nov-10 11:09 
QuestionA service to process scheduled tasks PinPopular
musefan29-Nov-10 4:46
musefan29-Nov-10 4:46 
AnswerRe: A service to process scheduled tasks Pin
#realJSOP29-Nov-10 4:50
mve#realJSOP29-Nov-10 4:50 
GeneralRe: A service to process scheduled tasks Pin
musefan29-Nov-10 5:21
musefan29-Nov-10 5:21 
GeneralRe: A service to process scheduled tasks Pin
#realJSOP29-Nov-10 6:00
mve#realJSOP29-Nov-10 6:00 
GeneralRe: A service to process scheduled tasks Pin
musefan29-Nov-10 6:09
musefan29-Nov-10 6:09 
AnswerRe: A service to process scheduled tasks Pin
Luc Pattyn29-Nov-10 5:01
sitebuilderLuc Pattyn29-Nov-10 5:01 
GeneralRe: A service to process scheduled tasks Pin
musefan29-Nov-10 5:33
musefan29-Nov-10 5:33 
AnswerRe: A service to process scheduled tasks Pin
Luc Pattyn29-Nov-10 6:35
sitebuilderLuc Pattyn29-Nov-10 6:35 
GeneralRe: A service to process scheduled tasks Pin
musefan29-Nov-10 6:43
musefan29-Nov-10 6:43 

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.