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

Can Time Ticks uniquely identify IIS requests?

hi,
i'm generating PDF files from crystal reports in my .Net 1.1 web site, and
saving them to disk for the user to download in their own time.

the format i'm currently using is: FileName_<DateTime.Now.Ticks>.PDF

there is a relatively low level of concurrent users on this site, but i am a
little concerned that two requests could happen within the same tick,
resulting in a filename clash and overwrite. is this possible? the docs
say a tick is 100 nanoseconds, which is a very short time i know. i have a
reasonable understanding of memory and disk access times, and the IIS/.Net
request life cycle, which would tell me that because disks are so relatively
slow, being measured in milliseconds, that IIS couldn't perform two
synchronous writes in the same tick. my nagging doubt is that two
simultaneous requests could run to the point in code where the file names
are calculated within the same tick, and then the disk I/O could be
executed.

i like having the Ticks in the file name because it is somewhat useful to me
that they are sequential. but if it is at all risky then i would change to
using a GUID in the filename.

any ideas? i know this is overkill to be concerned like this but i'm
interested anyway :)
many thanks in advance

tim mackey
Sep 11 '06 #1
3 1689
Hi,

Tim_Mac wrote:
hi,
i'm generating PDF files from crystal reports in my .Net 1.1 web site, and
saving them to disk for the user to download in their own time.

the format i'm currently using is: FileName_<DateTime.Now.Ticks>.PDF

there is a relatively low level of concurrent users on this site, but i am a
little concerned that two requests could happen within the same tick,
resulting in a filename clash and overwrite. is this possible? the docs
say a tick is 100 nanoseconds, which is a very short time i know. i have a
reasonable understanding of memory and disk access times, and the IIS/.Net
request life cycle, which would tell me that because disks are so relatively
slow, being measured in milliseconds, that IIS couldn't perform two
synchronous writes in the same tick. my nagging doubt is that two
simultaneous requests could run to the point in code where the file names
are calculated within the same tick, and then the disk I/O could be
executed.
If you want to avoid concurrent access to a critical resource (in that
case, that would be the clock), you must use the lock statement. For
example, you could use a class to generate the file names and save the
files, and enclose the critical section in

lock ( this )
{
// ...
}

This will ensure a sequential execution.

However, the requests will be processed in sequential order too, so the
risk is zero IMHO.

If you really, really want to make sure that the ID is unique *and*
incrementing, why don't you simply add an index?

private static long lIndexOfFile = 0;

and then

string strFileName = "FileName_"
+ DateTime.Now.Ticks + lIndexOfFile++ + ".PDF";

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 11 '06 #2
Hi Tim,

I would recommend to use GUID in the filename since DateTime.Now.Ticks is
not guaranteed to be unique.

By the way, is it supported in Crystal Reports to write the generated PDF
file to a stream instead of a file? If it's supported, then you may write
the PDF output the ASP.NET Response's output stream directly without using
a temporary file. Since Crystal Reports is not supported by Microsoft (see
http://support.microsoft.com/kb/100368/en-us for more info), you may have
to contact Crystal Reports for it.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 12 '06 #3
hi,
Laurent, thanks for the tip on using lock, i hadn't considered that
approach.
i think i'll just go with the GUIDs as Walter has suggested. it will give me
slightly better security in terms of malicious users trying to guess the URL
of a temp file. i clear them out every day with a script but even still, my
user population isn't very trustworthy!

Walter i was originally streaming the exported Crystal Reports to the Http
response as you suggested, but i found that very large reports (1000 page
PDFs) caused major problems both on server and client, hanging requests etc.
since i moved to a file based approach i have not had any of these problems
so i trust it a lot more. it also allows users to download the file in
their own time, i can show the status message and provide a hyperlink to
download the file.

thanks again for your help.
tim
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Oc**************@TK2MSFTNGXA01.phx.gbl...
Hi Tim,

I would recommend to use GUID in the filename since DateTime.Now.Ticks is
not guaranteed to be unique.

By the way, is it supported in Crystal Reports to write the generated PDF
file to a stream instead of a file? If it's supported, then you may write
the PDF output the ASP.NET Response's output stream directly without using
a temporary file. Since Crystal Reports is not supported by Microsoft (see
http://support.microsoft.com/kb/100368/en-us for more info), you may have
to contact Crystal Reports for it.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 12 '06 #4

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

Similar topics

2
by: kj | last post by:
In an earlier thread, JKrugman posted the following quote: > ...the purpose of XML namespaces is to uniquely identify element > and attribute names. Unprefixed attribute names can be uniquely...
0
by: Ross | last post by:
Hello everybody, When I try to configure my data adapter for ODBC I get the error "Could not determine which columns uniquely identify the rows for "Shipments"." This is for my update and delete...
2
by: muser8 | last post by:
What is the best way in which to uniquely identify anonymous visitors to an asp.net website? I'd like to create on online poll, but I want to guard against people hitting the refresh button,...
0
by: bazzer | last post by:
im trying to access a microsoft access database from an asp.net webform. but when i use the OdbcDataAdapter config wizard i get the following errors: *Generated UPDATE statement -could not...
1
by: Anoop Nair | last post by:
Hi I am developing scripts in C# which can be used to test windows based applications. I use Win32 API's to perform click operations etc. To uniquely identify a control in a window rather than ...
1
by: 01423481d | last post by:
Hi all Here is a segment of code used to find out all running processes Imports System.Diagnostics .... Dim myProcesses() As Process Dim myProcess As Process
6
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
6
by: Ryan Liu | last post by:
Hi, If I want to uniquely identify a computer. I can read CPU ID or Mac Address. I heard, but is this true: some BIOS can block CPU ID from being read? (In this case, will I get an exception,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.