Click here to Skip to main content
15,917,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: RSA-SHA1 Pin
SeMartens8-Dec-09 20:50
SeMartens8-Dec-09 20:50 
AnswerRe: RSA-SHA1 Pin
o m n i8-Dec-09 20:54
o m n i8-Dec-09 20:54 
GeneralRe: RSA-SHA1 Pin
satsumatable9-Dec-09 0:07
satsumatable9-Dec-09 0:07 
QuestionFunction for n number of users. Pin
Zafar Sultan8-Dec-09 20:11
Zafar Sultan8-Dec-09 20:11 
AnswerRe: Function for n number of users. Pin
mahmoudinirat8-Dec-09 20:16
mahmoudinirat8-Dec-09 20:16 
GeneralRe: Function for n number of users. Pin
Zafar Sultan8-Dec-09 21:03
Zafar Sultan8-Dec-09 21:03 
GeneralRe: Function for n number of users. Pin
mahmoudinirat8-Dec-09 21:11
mahmoudinirat8-Dec-09 21:11 
AnswerRe: Function for n number of users. Pin
Paulo Zemek9-Dec-09 2:37
Paulo Zemek9-Dec-09 2:37 
If I understood well, as soon as the next day arrives your want to execute the query for all users, right?

I use some code that has this type of functionality. Effectivelly, in Global.asax I create a new thread.
That thread will then, in a while(true) (yes, an infinite loop) wait for the next day.
Something like:
DateTime now = DateTime.Now;
DateTime nextDay = now.Date.AddDays(1);
TimeSpan diff = nextDay - now;
Thread.Sleep(diff);

And then, will execute the query for every user, sequentially. This way, you will not have problems when each user calls the method, that will only read the result. The method must only be prepared to know if the SP was run or not.

You can, for example, make every user wait for the SP to run using ReaderWriterLockSlim.
For example, you create a global (static) variable for the lock.
public static ReaderWriterLockSlim GlobalLock = new ReaderWriterLockSlim();

When you run the SP that calculates the values, you do the pattern:
GlobalLock.EnterWriteLock();
try
{
// execute the SP
}
finally
{
GlobalLock.ExitWriteLock();
}

And, at each user read you do:
GlobalLock.EnterReadLock();
try
{
// execute the SP
}
finally
{
GlobalLock.ExitReadLock();
}


This way, the users will wait until the SP finish before reading (considering they are calling the method at midnight).
GeneralRe: Function for n number of users. Pin
Zafar Sultan9-Dec-09 3:49
Zafar Sultan9-Dec-09 3:49 
QuestionPassing pointers 'round and 'round? Pin
o m n i8-Dec-09 18:54
o m n i8-Dec-09 18:54 
AnswerRe: Passing pointers 'round and 'round? Pin
dan!sh 8-Dec-09 19:19
professional dan!sh 8-Dec-09 19:19 
GeneralRe: Passing pointers 'round and 'round? Pin
o m n i8-Dec-09 19:58
o m n i8-Dec-09 19:58 
GeneralRe: Passing pointers 'round and 'round? Pin
Richard MacCutchan8-Dec-09 22:25
mveRichard MacCutchan8-Dec-09 22:25 
QuestionC++ project to c# Pin
faheemnadeem8-Dec-09 18:37
faheemnadeem8-Dec-09 18:37 
AnswerRe: C++ project to c# Pin
dan!sh 8-Dec-09 18:42
professional dan!sh 8-Dec-09 18:42 
GeneralRe: C++ project to c# Pin
faheemnadeem8-Dec-09 19:22
faheemnadeem8-Dec-09 19:22 
AnswerRe: C++ project to c# Pin
N a v a n e e t h8-Dec-09 20:56
N a v a n e e t h8-Dec-09 20:56 
AnswerRe: C++ project to c# Pin
Dave Doknjas9-Dec-09 11:49
Dave Doknjas9-Dec-09 11:49 
QuestionMe, again... Confused Again... Pin
Roger Wright8-Dec-09 18:29
professionalRoger Wright8-Dec-09 18:29 
AnswerRe: Me, again... Confused Again... Pin
dan!sh 8-Dec-09 18:46
professional dan!sh 8-Dec-09 18:46 
GeneralRe: Me, again... Confused Again... Pin
Roger Wright8-Dec-09 18:52
professionalRoger Wright8-Dec-09 18:52 
GeneralRe: Me, again... Confused Again... Pin
dan!sh 8-Dec-09 19:11
professional dan!sh 8-Dec-09 19:11 
GeneralRe: Me, again... Confused Again... Pin
Roger Wright8-Dec-09 19:19
professionalRoger Wright8-Dec-09 19:19 
GeneralRe: Me, again... Confused Again... Pin
dan!sh 8-Dec-09 19:20
professional dan!sh 8-Dec-09 19:20 
GeneralRe: Me, again... Confused Again... Pin
Roger Wright8-Dec-09 20:17
professionalRoger Wright8-Dec-09 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.