HighTechTalks DotNet Forums  

Is this a read/write race condition?

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Is this a read/write race condition? in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
antonyliu2002@yahoo.com
 
Posts: n/a

Default Is this a read/write race condition? - 07-26-2007 , 12:01 PM






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.

Quote:
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.



Reply With Quote
  #2  
Old   
Lloyd Sheen
 
Posts: n/a

Default Re: Is this a read/write race condition? - 07-26-2007 , 01:19 PM







<antonyliu2002 (AT) yahoo (DOT) com> wrote

Quote:
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



Reply With Quote
  #3  
Old   
antonyliu2002@yahoo.com
 
Posts: n/a

Default Re: Is this a read/write race condition? - 07-26-2007 , 02:10 PM



On Jul 26, 1:19 pm, "Lloyd Sheen" <a...@b.c> wrote:
Quote:
antonyliu2... (AT) yahoo (DOT) com> wrote in message

news:1185465692.824127.146650 (AT) l70g2000hse (DOT) googlegroups.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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.