1

Possible Duplicate:
ASP.Net:Best way to run scheduled tasks

How to fire a server side action after 10 minutes in ASP.NET using C#

For example of, if user creates an account and if his account is kept inactive for 12 hours how to automatically delete his account. I need something related to this kind of example.

There should be no relation with browser. Once the user logs out of his account his some server side action to be performed automatically after some certain time.

Community
  • 1
  • 1
Karthik Malla
  • 5,570
  • 12
  • 46
  • 89
  • 2
    Do you really understand what you are asking? – stefan Mar 01 '11 at 17:29
  • 1
    I think a windows service might be better suited for those kind of cleanup/management tasks – BrokenGlass Mar 01 '11 at 17:30
  • What do you mean by automatic deletion why you need this – Developer Mar 01 '11 at 17:30
  • @stefan, @dorababu : I just gave you an example. It might be a deletion of an account in a database or some other of our choice... – Karthik Malla Mar 01 '11 at 17:37
  • @stefan - if u cannot answer/if u don't have knowledge towards this subject I hope its better not to comment on this. Hope u understood my point :-) – Karthik Malla Mar 01 '11 at 17:39
  • @Karthik Malla Iam not going to do your coding for you, and I doubt thats what SO is all about? If it is moderators could just zap my account :) – stefan Mar 01 '11 at 17:41
  • @stefan - I already told you in clear its just an example of a server side timer action. But I have a lot to do with that. Such things really helps in developing secured projects. – Karthik Malla Mar 01 '11 at 17:50

4 Answers4

0

This thread seems to have some solutions related to your problem.

Community
  • 1
  • 1
0

To have some code running for sure no matter people closing the browser or even IIS recycling, you should have a windows service running on the server then you could use in it some kind of task scheduling framework.

I would rather solve this having a cleanup job running once a day for example, I would devote effort in writing the job logic in itself ( if really needed ), then I would let windows task scheduling service to call my job so no time wasted reinventing the wheel...

Davide Piras
  • 43,984
  • 10
  • 98
  • 147
0

Have you considered using a web service? This would run independent of the browser and can run long term timer events for you.

http://msdn.microsoft.com/en-us/library/t745kdsh.aspx

Infotekka
  • 10,307
  • 2
  • 20
  • 17
0

i would setup a Timer Method in the global.asax, which then can do the cleanup operations.

Therefor you add the following code to the Application_Start:

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

'--Save Translations every 15minutes, starting 15sec after appstart Dim TimerDelegate As Threading.TimerCallback = AddressOf Manager.DoWork

Dim MyTimer As Threading.Timer = New Threading.Timer(TimerDelegate, Nothing, TimeSpan.FromSeconds(15), TimeSpan.FromMinutes(10))

End Sub

and implement a e.g. Manager with the Worker-Method: Manager.vb:

public shared sub DoWork()

'--Dow the work...

end sub

Christoph
  • 915
  • 1
  • 12
  • 23
  • Hello Chris, your answer is correct... but may I expect the same syntax in c# – Karthik Malla Mar 01 '11 at 17:42
  • As i cannot post code as a comment try converting the code fragments with this online tool: http://www.developerfusion.com/tools/convert/vb-to-csharp/ – Christoph Mar 02 '11 at 14:30