|
-
August 23rd, 2011, 08:47 PM
#1
Need Advice - Opening a file once and reading data every time a method is called
Hi,
I was not sure what section to post this but I thought this was the most appropriate. I have a bit of a strange programming problem because I am forced to use a number of closed formats and tools and only have access to my own code that hooks into their system as well as some dlls that allow me to read their data files. I should also say I am fairly new to C# programming and programming in .NET so I am often not sure what tools I have at my disposal.
I have a C# project that has in it a method that I am working on. This method is called regularly (once every few seconds) by the company's system. When my method is called I need to open a data file using the company's file IO API, read some of the data, once again using their API, and then do some interpretation of this and pass back to their software some information which it then uses, and after this the process repeats itself, calling my method once again where I get new data from the file and do my processing of it. The problem I am having is that obtaining the file object occasionally fails. In my discussion with an employee at the company he suggests that I might not be able to open the file safely that often, as it is being opened every time the method is called, and suggested I try to come up with some method where the data file is opened once and kept open and during each iteration of my method I can read from this open file.
The problem I have is that I am not really sure how I can accomplish this when the only access I have is modifying this method that is constantly being called. Is it possible to somehow start a thread the first time my method is called to provide access to the file, opening it and then doling out new data each time the method is called after this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|