Is this a read/write race condition?

Discussion in 'ASP .Net' started by antonyliu2002@yahoo.com, Jul 26, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. Lloyd Sheen Guest

    <> wrote in message
    news:...
    >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
     
    Lloyd Sheen, Jul 26, 2007
    #2
    1. Advertising

  3. Guest

    On Jul 26, 1:19 pm, "Lloyd Sheen" <> wrote:
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > >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, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jimjim

    race condition question

    jimjim, Nov 1, 2003, in forum: Java
    Replies:
    6
    Views:
    434
    jimjim
    Nov 2, 2003
  2. Replies:
    1
    Views:
    375
    Kevin Spencer
    Aug 7, 2006
  3. Replies:
    3
    Views:
    760
  4. fran
    Replies:
    2
    Views:
    534
  5. techi_C
    Replies:
    2
    Views:
    1,491
    Richard Bos
    Aug 10, 2006
Loading...

Share This Page