473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Share Process

Hello all,

I am developing a application in c#.NET for Windows CE 5.0 device.
1) Need to process some information - Which is i am doing fine no problem.
2) I need to record some data into a one file in continuosly.

My problem is writting data into file is killing the process time. For one cycle processing time is around 180 ms to write. So i decided to use reflections which use another exe to write the data into a file continulosly.

But the type.invokemember() function is not supporting for Windows CE 5.0.

I am using .NET Compact Frame work 2.0.

My ultimate aim is to complete the file write process with in 10 ms. (only for file write). Could you please suggest some idea to implement this.

Thanks in advance.
Rajesh G
Oct 26 '09 #1
9 1947
tlhintoq
3,525 Expert 2GB
How much data are you writting?
What is the media you are writing to?

You can *want* to write 500mb in 10ms for example, but you can't do better than the drive is capable of.
Oct 26 '09 #2
I am using USB 2.0 Speed flash memory. I am writting 500bytes of information into a file for every 10ms. I hope the 2.0 is better speed to achive wrtting data with in 10ms.
Oct 27 '09 #3
tlhintoq
3,525 Expert 2GB
Unlikely.
Keep in mind:
For your 500 bytes of data there is probably more than 500bytes in communication overhead to open and close the file.
Flash drives are netoriously slow when writing. They are faster when reading.
Flash memory is rated for a limited number of writes. They will fail and their lifespan is not as long as a hard drive.

I might suggest a scheme were you write to a class every 10ms and have that class hold the data. Then after every 50 lines of input, write that to the flash memory on a separate thread. Now you still record all your data at 10ms, but you are only writing every 500ms.
Oct 27 '09 #4
I measured the file write() will write the data into a file with in 2ms but file flush function is consuming more time to save the contents. The auto flush = true is calling flush function after every filewrite.
Is there any way to save the file without calling file flush?
Oct 27 '09 #5
tlhintoq
3,525 Expert 2GB
Can I see your file write routine?
Oct 27 '09 #6
Expand|Select|Wrap|Line Numbers
  1. public partial class Form1 : Form
  2.     {
  3.         public long Start_Tick_Count = 0;
  4.         public long End_Tick_Count = 0;
  5.         DateTime SystemDate;
  6.         public string data = "";
  7.         int Count = 0;
  8.         TextWriter TextFile = new StreamWriter("File1.txt");    
  9.  
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.  
  15.         private void button1_Click(object sender, EventArgs e)
  16.         {
  17.  
  18.             Application.Exit();  
  19.         }
  20.  
  21.         private void Form1_Load(object sender, EventArgs e)
  22.         {
  23.            SystemDate = DateTime.Now;
  24.  
  25.         }
  26.  
  27.         private void timer1_Tick_1(object sender, EventArgs e)
  28.         {
  29.             int Index = 0;
  30.             Start_Tick_Count = System.Environment.TickCount;
  31.             listBox1.Items.Add(Convert.ToString(Start_Tick_Count - End_Tick_Count));
  32.             SystemDate = SystemDate.AddMilliseconds(Start_Tick_Count - End_Tick_Count);
  33.             End_Tick_Count = System.Environment.TickCount;
  34.  
  35.             for (Index = 0; Index <= 256; Index++)
  36.             {
  37.                 label1.Text = SystemDate.ToString("yyyy-MM-dd-hh:mm:ss:fff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
  38.                 data = label1.Text;
  39.                 TextFile.WriteLine(data);  
  40.                 //TextFile.Flush(); 
  41.             }
  42.  
  43.             if (Count > 19)
  44.             {
  45.                 Count = 0;
  46.                 TextFile.Flush(); 
  47.             }
  48.             else
  49.                 Count = Count + 1;
  50.  
  51.         }
  52.  
  53.  
  54.     }
  55. }
In the above application, while executing the file flush function the application processing time increases.
Oct 27 '09 #7
tlhintoq
3,525 Expert 2GB
TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Oct 27 '09 #8
tlhintoq
3,525 Expert 2GB
You said you were writing data every 10ms.
You are really doing MORE than just writing data. Much of which seems pointless to me.
What I don't see is any *data* being passed or written. Just the time.

A loop that seems to do nothing more than count to 255, writing a line every time?
Expand|Select|Wrap|Line Numbers
  1. for (Index = 0; Index <= 256; Index++)
  2.             {
  3.                 label1.Text = SystemDate.ToString("yyyy-MM-dd-hh:mm:ss:fff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
  4.                 data = label1.Text;
  5.                 TextFile.WriteLine(data);  
  6.                 //TextFile.Flush(); 
  7.             }
What's all the zeros in the DateTime format?
Is there a reason you are setting all this into a label then getting it back out again before writing it to your file? Labels are not fast controls.


As for the actual writing part... I've never used TextWriter so I can't tell you if it is good/bad or otherwise.

Here is (part of) how I write my log files to hard drive:
string szEntryText is the text parameter passed into the method further up than shown here.
Expand|Select|Wrap|Line Numbers
  1. DateTime pModDate = DateTime.Now;
  2. szEntryText = string.Format("{0}\t{1}\t{2}",
  3.                             pModDate.ToString("ddMMMyy"),
  4.                             pModDate.ToString("HH:mm:ss.fff"),
  5.                             szEntryText);
  6. // Date {tab} time {tab} entrytext
  7.  
  8. try
  9. {
  10.     using (FileStream fs = new FileStream(szFileName, FileMode.Append))
  11.     {
  12.         //Encoding isoWesternEuropean = Encoding.GetEncoding(28591);
  13.         //using (StreamWriter w = new StreamWriter(fs, isoWesternEuropean))
  14.         using (StreamWriter w = new StreamWriter(fs, Encoding.Unicode))
  15.         {
  16.             w.WriteLine(szEntryText);
  17.             //w.Close(); // bad
  18.             Console.WriteLine(szEntryText);// For running from Visual Studio debugger
  19.         } // end using StreamWriter
  20.         //fs.Close(); // bad
  21.     }// End using FileStream
  22.     // w and fs now out of scope therefore
  23. } // end try
  24.  
  25. catch (Exception err)
  26. {
  27.     Console.WriteLine("Log write error: " + err.Message);
  28. }
  29. // Both FileStream and StreamWriter close themselves when they fall out of scope of their respective using statement
  30.  
Oct 27 '09 #9
You sugesstion is valuable. But that doesnt save any process time. So thats the reason i want to run another process. I will transfer the information to write through main process. Like in reflection. Even i tried in threads doesnt save any processing time.
Oct 27 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ruslan A Dautkhanov | last post by:
Hello ! I have complex system, which use PostgreSQL as a storage. Web-interface use Apache+mod_perl, Pg.pm for connection. I also have kernel of the system written in C++, which works as a UNIX...
3
by: kyle.tk | last post by:
So I have a central list of python objects that I want to be able to share between different process that are possibly on different computers on the network. Some of the processes will add objects...
7
by: Frank Rizzo | last post by:
Hello, I've asked this question in the languages.vb group, but got no response, so I'll try my luck here. My app needs to copy a file from a local folder to a network share. The network share...
1
by: brian.oneil2 | last post by:
Is there a way to install this onto a network file share and allow a team to access it? I would say share a CD from a networked CD drive, but there are multiple CD's that would have to be inserted....
7
by: isamusetu | last post by:
anybody knows how to share the dll between the process? I know there is a way to set the #pragma data_seg in the visual studio 6.0 C++, that can make the dll can be shared between the multiple...
4
by: Jeremy S. | last post by:
We're in the process of writing a new Windows Forms app and the desktop support folks want for it to be run from a network share. I know it's possible (i.e., just have the framework on the clients...
1
by: | last post by:
In C++, I can create a share memory that can be share by different processes to use it. But in C#, how can I share data between process and process, ? and between AppDomain and AppDomain? Thanks
0
by: Steve | last post by:
Hello- Platform: - web server using IIS 6 connecting to UNC share on separate file server - Both servers are Windows 2003 with dotNetFramework 2.0 General: - basic ASP.NET pages work fine...
5
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I am trying to accesss a Mapped Drive from my asp.net code running on IIS 6.0. I am using a FileUpload control and fileUpload.SaveAs() to save the file to the server. I want to save the file to...
6
by: Immortal Nephi | last post by:
First class is the base class. It has two data: m_Base1 and m_Base2. Second class and third class are derived classes and they are derived from first class. m_Base1 and m_Base2 are inherited into...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.