473,738 Members | 5,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2026

<an***********@ yahoo.comwrote in message
news:11******** **************@ l70g2000hse.goo glegroups.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.cwrot e:
<antonyliu2...@ yahoo.comwrote in message

news:11******** **************@ l70g2000hse.goo glegroups.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
15827
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. He's wrong. Right? Two users in a web session could both access a static method at the same time and never have any trouble.
6
8767
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 produces an output file repeatedly, simulating the input file separately for each replicate. The error occurs when trying to open the input file to write out the new data. The problem is difficult to reproduce since it only shows up once every few...
5
2573
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 because in the file pytz/tzinfo.py, I see global variables _timedelta_cache, _datetime_cache, _ttinfo_cache, which are dictionnaries and are used as cache. I always thought that you must protect shared data with locks when multithreading, but I don't...
3
2448
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 external files contains a class A. The inline JS then inherits a class B from A. My question is now, since the class A is defined in the external file, is the class A definitely known at the point where I use it? I could
18
5858
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 component becomes instabile, throwing a Windows like error (access violation on 0x00000002), not an framework exception. The component and all of its subcomponents are 100% managed code. What could go wrong with Thread.Abort()? Thanks for any hints.
3
2982
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 for Item (this)? Normally,do I need sync at all? Isn't that true without sync the program can run faster?
92
9357
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
5408
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 think it is mostly not going to happen for ++ operation since it is not something like read a value and wait sometime then write back in multiple threading environment, BTW, is this understanding right?).
7
2307
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 succeeds IF i walk through the debugger and IF I examine the ListViewItem's properties in the debugger visualizer. Otherwise, it fails. Any ideas? Thanks. BH
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.