ASP.NET (thread safe? ) Page / DTS Package execution.

D

dwight0

I have a DTS package that can be execute from ASP.net and I was
wondering if there is a way to make this thread safe some how. I know
thread safe isn't exactly the word I'm looking for but let me know
what the correct term is. What I have is an asp.net page that executes
a DTS package and I want to be sure no two people will click a submit
button on this page from 2 different computers at the same time. And if
they do I want one to be locked until the other person's request is
done processing or at least notify the user to try again. I would
prefer to find a way to notify the person and do this in ASP.net
because I have some other pages that need to be done this way with
plain SQL update queries that aren't DTS;(I do use transactions and
locking) but I was wondering if I can just find out of another person
is on the same page, or if its processing that page from another
instance of Iexplorer. If this isn't possible, a way to prevent this
in the DTS package would work almost as well. Any ideas are
appreciated, Thanks!
 
S

Scott Allen

Dwight:

You can wrap the code inside of a Monitor.TryEnter and a Monitor.Exit. Specify
a timeout value for TryEnter and if the method returns a false - someone
else still has the lock and you can notify the user. A Monitor will only
permit one thread to execute the code it is guarding.
 
D

dwight0

I thought of that, i didnt try it because i didnt think it would work
that way in ASP.net. Im not too famaliar with the inner workings but i
just assumed that wouldnt apply in asp.net like it does in windows
forms. I will still try it. Its difficult to reproduce the problem I
am having. Ill keep you updated.
 
D

dwight0

I was just thinking. Would the monitor still work on a dual processor
cpu ? Im not totaly sure how far up the monitor goes, but possibly to
the appdomain? Im not sure, but im wondering if each processor gets an
appdomain. Im also wondering if i should or could use the application
object to store a boolean weather its locked. I might be going
overboard but for some reason I keep having a doubt that the monitor is
safe. i thought about using a static class to help but im not sure when
it would get destroyed. (im not just asking scott, but whomever)
Thanks!
-Dwight
 
S

Scott Allen

Monitors do work on MP machines - if they didn't we'd all be in big
trouble :).

Monitors do not work across appdomains. In general you won't have to
worry about that unless you have webgardens enabled on a 2003 server.
A static isn't necessarily the whole solution, as you'd still need to
synchronize access to the static member.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top