473,386 Members | 2,114 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,386 software developers and data experts.

Is this a read/write race condition?

I do not quite understand the race condition.

As I posted a couple of days ago, I create a PDF on the fly in my web
application at regular intervals. Users will be able to download the
PDF file.

Suppose, at the time when my application is in the process of
generating the PDF file (which takes around 2.5 minutes), a user tries
to download it, will this be a problem?

I checked the Lock method of FileStream. The description of this
method says:

Prevents other processes from changing the FileStream while permitting
read access.
>From the description, read access is permitted even if the stream is
locked. So, it looks like the creation of the PDF file and the
downloading of this file can happen at the same time without a
problem, right?

Thanks.

Jul 26 '07 #1
2 2010

<an***********@yahoo.comwrote in message
news:11**********************@l70g2000hse.googlegr oups.com...
>I do not quite understand the race condition.

As I posted a couple of days ago, I create a PDF on the fly in my web
application at regular intervals. Users will be able to download the
PDF file.

Suppose, at the time when my application is in the process of
generating the PDF file (which takes around 2.5 minutes), a user tries
to download it, will this be a problem?

I checked the Lock method of FileStream. The description of this
method says:

Prevents other processes from changing the FileStream while permitting
read access.
>>From the description, read access is permitted even if the stream is
locked. So, it looks like the creation of the PDF file and the
downloading of this file can happen at the same time without a
problem, right?

Thanks.
Perhaps you could do one of the following:

1. Create the PDF with a different name than the name which users will
download. Once the PDF is created then delete the old one and change the
name of the new one to the download name.

2. Disable the mechanism (button ??) to download the file while a new on is
being created.

Hope this helps,

Lloyd Sheen

Jul 26 '07 #2
On Jul 26, 1:19 pm, "Lloyd Sheen" <a...@b.cwrote:
<antonyliu2...@yahoo.comwrote in message

news:11**********************@l70g2000hse.googlegr oups.com...
I do not quite understand the race condition.
As I posted a couple of days ago, I create a PDF on the fly in my web
application at regular intervals. Users will be able to download the
PDF file.
Suppose, at the time when my application is in the process of
generating the PDF file (which takes around 2.5 minutes), a user tries
to download it, will this be a problem?
I checked the Lock method of FileStream. The description of this
method says:
Prevents other processes from changing the FileStream while permitting
read access.
>From the description, read access is permitted even if the stream is
locked. So, it looks like the creation of the PDF file and the
downloading of this file can happen at the same time without a
problem, right?
Thanks.

Perhaps you could do one of the following:

1. Create the PDF with a different name than the name which users will
download. Once the PDF is created then delete the old one and change the
name of the new one to the download name.

2. Disable the mechanism (button ??) to download the file while a new on is
being created.

Hope this helps,

Lloyd Sheen
Hi, Lloyd,

Thanks. your idea 1 is absolutely a good solution, since changing the
file name is only a flash of second in an application. That will
certainly reduce the probability of race condition otherwise imposed
in a 2.5-minute duration when the PDF file is being created.

Jul 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: GIMME | last post by:
One of my coworkers insists that one should never use static methods because race conditions exist. Thinking along the lines that all variable assignments are assignments to static variables. ...
6
by: haynesc | last post by:
Hi, I'm having a problem where when trying to open a file in write mode, I get an IOError stating no such file or directory. I'm calling an external program which takes an input file and...
5
by: nicolas_riesch | last post by:
Does someone know if the module pytz (http://sourceforge.net/projects/pytz/) is thread-safe ? I have not seen it explicitely stated, and just wanted to be sure, as I want to use it. That's...
3
by: Juergen Stein | last post by:
Hi Group, I couldn't find an answer on this with Google, so let me test you :) I've a fairly complex WebApp, and I put most of the JS code in independent external .js files. One of these...
18
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
3
by: Ryan Liu | last post by:
Hi, What does ArrayList.Synchronized really do for an ArrayList? Is that equal to add lock(this) for all its public methods and properties? Not just for Add()/Insert()/Remvoe()/Count, but also...
92
by: quickcur | last post by:
Hi, can anyone point me a library that can read image to memory from a URL? It is very easy in Java, but it is hard to find an complete solution in c/c++. Thanks,
17
by: Ryan Liu | last post by:
Hi, If I have many threads write to a variable(e.g. var++) and another thread read it on an interval base. For those writing thread, I know I need lock, or its value could be lower ( even I...
7
by: Berryl Hesh | last post by:
I wouldn't nomally post this here, as it has something to do with the ListView control usage I think, or maybe with a race condition or some windoes messaging. I'm just not sure. The test below...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.