Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:43:57+00:00 2026-05-14T00:43:57+00:00

I have small web app that generate PDF files as a report. I’m trying

  • 0

I have small web app that generate PDF files as a report. I’m trying to delete those generated PDF files after 10 sec that they are generated. What I want to do is to read a folder with PDF files every 10 sec, and delete all the PDF files inside that folder.

I read this post of Easy Background Tasks in ASP.NET. The following code is the VB version.

    Protected Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    AddTask("DoStuff", 10)
End Sub

Private Sub AddTask(ByVal name As String, ByVal seconds As Integer)
    OnCacheRemove = New CacheItemRemovedCallback(CacheItemRemoved)
    HttpRuntime.Cache.Insert(name, seconds, Nothing, DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, _
     OnCacheRemove)
End Sub

Public Sub CacheItemRemoved(ByVal k As String, ByVal v As Object, ByVal r As CacheItemRemovedReason)
    ' do stuff here if it matches our taskname, like WebRequest

    DeletePDFilesInFoler()

    ' re-add our task so it recurs
AddTask(k, Convert.ToInt32(v))

End Sub

But I got this error

Delegate
‘System.Web.Caching.CacheItemRemovedCallback’
requires an ‘AddressOf’ expression or
lambda expression as the only argument
to its constructor.

If this code works, where I should put it. Right, now I’m putting it in the master page. How to get this error out?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:43:57+00:00Added an answer on May 14, 2026 at 12:43 am

    Rather than deleting them on a schedule, why not look for old PDFs and delete them each time a PDF is generated?

    Pseudo-code:

    /* Clean up old PDFs */
    If Not StaticCleaningUpPDFsNow Then
       // No other reports generating simultaneously and trying to delete old PDFs
       StaticCleaningUpPDFsNow = True 
       For each f in (reportfolder\*.pdf)
          If f.DateCreated.AddSeconds(10) < Now Then f.Delete
       Next
       StaticCleaningUpPDFsNow = False
    End If
    /* Create PDF for the current report */
    ...
    

    The overhead to look for files in a folder and delete a few is incredibly small, and doing this on demand is a much better use of resources, without the hacks around cache expirations (and the edge cases that can result).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a broke college student. I have built a small web app in
I'm making a small web application in Seaside. I have a login component, and
I'm the leader of a small web development team, and I have a feeling
I have a small project I am doing in Python using web.py. It's a
I am developing a small intranet based web application. I have YSlow installed and
I have a small JS function that does Ajax for me and another like
I'm writing a small webapp in Grails and I have the following question regarding
I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have small problem with my .net 2.0 winforms application. I want to embed
Where I work, we have small teams of 2 - 5 people. As a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.