Hi
I have a problem with this

Public Class SendPings
    Shared Sub New()
        AddHandler Post.Saved, AddressOf Post_Saved
        AddHandler Page.Saved, AddressOf Post_Saved
    End Sub

    Private Shared Sub Post_Saved(ByVal sender As Object, ByVal e As SavedEventArgs)
        If e.Action = SaveAction.None OrElse e.Action = SaveAction.Delete Then
            Exit Sub
        End If

        Dim item As IPublishable = DirectCast(sender, IPublishable)
        If item.IsVisibleToPublic Then
            Dim url As Uri = item.AbsoluteLink
            ThreadPool.QueueUserWorkItem(AddressOf [B][U]Ping[/U][/B], item)
           
        End If
       
    End Sub

    Private Shared Sub Ping(ByVal item As IPublishable, ByVal itemUrl As Uri)
        Try
            System.Threading.Thread.Sleep(2000)
           BlogEngine.Core.Ping.PingService.Send(itemUrl)
           If Not BlogSettings.Instance.EnableTrackBackSend AndAlso Not BlogSettings.Instance.EnablePingBackSend Then
                Exit Sub
            End If

            If item.Content.ToUpperInvariant().Contains("""HTTP") Then
                BlogEngine.Core.Ping.Manager.Send(item, itemUrl)
            End If
        Catch generatedExceptionName As Exception
            ' We need to catch this exception so the application doesn't get killed.
        End Try
    End Sub

End Class

I get a error

Method 'Private Shared Sub Ping(item As BlogEngine.Core.IPublishable, itemUrl As System.Uri)' does not have a signature compatible with delegate 'Delegate Sub WaitCallback(state As Object)'.

can help me?

Recommended Answers

All 3 Replies

How did you call that method? Can you post the code for that method call?

here it is the code for that method call

Imports System
Imports System.Web
Imports BlogEngine.Core.Web.Controls
Imports BlogEngine.Core
Imports System.Net.Mail
Imports System.Threading

<Extension("Pings all the ping services specified on the PingServices admin page and send track- and pingbacks", "1.3", "test.net")> _
Public Class SendPings
    Shared Sub New()
        AddHandler Post.Saved, AddressOf Post_Saved
        AddHandler Page.Saved, AddressOf Post_Saved
    End Sub

    Private Shared Sub Post_Saved(ByVal sender As Object, ByVal e As SavedEventArgs)
        If e.Action = SaveAction.None OrElse e.Action = SaveAction.Delete Then
            Exit Sub
        End If

        Dim item As IPublishable = DirectCast(sender, IPublishable)
        If item.IsVisibleToPublic Then
            Dim url As Uri = item.AbsoluteLink
            ThreadPool.QueueUserWorkItem(AddressOf Ping, item)
        End If
      
    End Sub

    Private Shared Sub Ping(ByVal item As IPublishable, ByVal itemUrl As Uri)
        Try
            System.Threading.Thread.Sleep(2000)

            ' Ping the specified ping services.
            BlogEngine.Core.Ping.PingService.Send(itemUrl)

            ' Send trackbacks and pingbacks.
            If Not BlogSettings.Instance.EnableTrackBackSend AndAlso Not BlogSettings.Instance.EnablePingBackSend Then
                Exit Sub
            End If

            If item.Content.ToUpperInvariant().Contains("""HTTP") Then
                BlogEngine.Core.Ping.Manager.Send(item, itemUrl)
            End If
        Catch generatedExceptionName As Exception
            ' We need to catch this exception so the application doesn't get killed.
        End Try
    End Sub

End Class

You should make a ThreadProcedure for the Ping() method:

Chanage "Ping" to "PingProc":

ThreadPool.QueueUserWorkItem(AddressOf [B]PingProc[/B], item)

Add a new method:

Change arg1 & arg2 with arguments you want to use.

Shared Sub PingProc(stateInfo As Object)

   Ping(arg1, arg2);

End Sub

Hope that helps.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.