Welcome to MSDN Blogs Sign in | Join | Help

Microsoft RSS Blog

All about RSS and feed technology at Microsoft and across the community
Events in VB.NET

We’ve been getting a few questions on how to use RSS Platform events in VB.NET. The problem faced by most inquiries was the fact that the interface returned by the GetWatcher() method call couldn’t be cast to the FeedFolderWatcher or FeedWatcher type. Instead the returned interface can be cast to IFeedFolderEvents_Event or IFeedEvents_Event interface. As done here:

Imports Microsoft.Feeds.Interop

Module Module1

Dim WithEvents watcher As IFeedFolderEvents_Event

Sub Main()

Dim fm As IFeedsManager = New FeedsManager()

Dim rootFolder As IFeedFolder = fm.RootFolder

watcher = rootFolder.GetWatcher(FEEDS_EVENTS_SCOPE.FES_ALL, FEEDS_EVENTS_MASK.FEM_FOLDEREVENTS)

AddHandler watcher.FeedDownloading, AddressOf watcher_Downloading

End Sub

Sub watcher_Downloading(ByVal path As String)

Console.WriteLine("Downloading {0}", path)

End Sub

Sub watcher_DownloadCompleted(ByVal path As String, ByVal err As FEEDS_DOWNLOAD_ERROR) Handles watcher.FeedDownloadCompleted

Console.WriteLine("Downloaded {0}", path)

End Sub

End Module

 

The key is the highlighted part.

Note: We are aware that the IFeedFolderEvents_Event and IFeedEvents_Event interfaces do not appear in the Object Browser or in IntelliSense. We are looking into it.

Keep the feedback coming!

-Walter vonKoch

Posted: Thursday, June 08, 2006 6:16 AM by rss
Filed under:

Comments

Hannes Preishuber said:

cool

thanks

this helps me a lot, i had a solution before ( tray icon notification) but the path was empty in folderitemcountchanged event
now i use downloadcompleted

Add question: sometime RSS downloading stops, only machine restarts help. Any idea?
ps: private mail hannesp [AT] ppedv.de
# June 9, 2006 2:30 AM

Andrew Davey said:

I still think getting a decent managed wrapper is a top priority. All this COM interop is going to be a huge barrier to entry for morts who just want to play with MSFeeds.
# June 9, 2006 7:40 AM

rss said:

Andrew, am I correct to infer that by "all this com interop" you mean that it's necessary to cast the returned objects to the correct interfaces?

- Walter [MSFT]
# June 15, 2006 12:01 AM

Ron said:

Thanks for posting this Walter.  I wanted to add that it's not necessary to include the AddHandler instructions in VB.net.

If you have ...

Dim WithEvents watcher As IFeedFolderEvents_Event

... all you need is the corresponding subroutine definition that includes the "handles" option.

Sub watcher_DownloadCompleted(ByVal path As String, ByVal err As FEEDS_DOWNLOAD_ERROR) Handles watcher.FeedDownloadCompleted

In fact, Visual Studio will build the sub routine stub for you if you select the appropriate class name and method name in the code view drop drowns.

Regards,
Ron
# June 19, 2006 1:32 PM

rss said:

Ron, you are correct, it's not necessary to include the AddHanlder instruction. I used both methods in the code sample so people can choose according to their preference.
I should have mentioned that in the post. Thanks for pointing it out!

-Walter [MSFT]
# June 19, 2006 7:39 PM

denkel said:

Hi, I’m Asbjørn. Don’t know if this is the right place to subscribe this problem, but her I go.

We have some problems with RSS and the new IE7.2. The RSS-feeds works fine, but the homepage where we publish ours RSS-news doesn’t work in the browser. It look’s like the browser is taking a screen dump of the RSS-news, so you can’t scroll in the news. This wasn’t a problem in the old IE. We will like to have both the feeds and the browser working. The URL for the problem is http://www.econ.ku.dk/polit/news.asp.

My question: Is this script error, and if yes, what are the soloution? Or will the problem be solved in the new IE?  
# June 28, 2006 5:39 AM

program said:

Very good . You are doing a great job.

# August 20, 2007 2:48 AM

LFERC said:

Thanks for posting this Walter.  I wanted to add that it's not necessary to include the AddHandler instructions in VB.net.

If you have ...

Dim WithEvents watcher As IFeedFolderEvents_Event

... all you need is the corresponding subroutine definition that includes the "handles" option.

Sub watcher_DownloadCompleted(ByVal path As String, ByVal err As FEEDS_DOWNLOAD_ERROR) Handles watcher.FeedDownloadCompleted

In fact, Visual Studio will build the sub routine stub for you if you select the appropriate class name and method name in the code view drop drowns.

Regards,

Ron

# January 19, 2008 7:23 AM

Vista said:

cool

thanks

this helps me a lot, i had a solution before ( tray icon notification) but the path was empty in folderitemcountchanged event

now i use downloadcompleted

Add question: sometime RSS downloading stops, only machine restarts help. Any idea?

ps: private mail hannesp [AT] ppedv.de

# January 19, 2008 7:23 AM

Veridominique said:

I still think getting a decent managed wrapper is a top priority. All this COM interop is going to be a huge barrier to entry for morts who just want to play with MSFeeds.

# January 19, 2008 7:24 AM

Webhosting said:

Ron, you are correct, it's not necessary to include the AddHanlder instruction. I used both methods in the code sample so people can choose according to their preference.

I should have mentioned that in the post. Thanks for pointing it out!

-Walter [MSFT]

# January 19, 2008 7:24 AM

Thisare said:

Hi, I’m Asbjørn. Don’t know if this is the right place to subscribe this problem, but her I go.

We have some problems with RSS and the new IE7.2. The RSS-feeds works fine, but the homepage where we publish ours RSS-news doesn’t work in the browser. It look’s like the browser is taking a screen dump of the RSS-news, so you can’t scroll in the news. This wasn’t a problem in the old IE. We will like to have both the feeds and the browser working. The URL for the problem is http://www.econ.ku.dk/polit/news.asp.

My question: Is this script error, and if yes, what are the soloution? Or will the problem be solved in the new IE?  

# January 19, 2008 7:25 AM

encyclopedia reference said:

Nice solution. I've been looking for this.

# March 19, 2008 7:35 PM

Kosmetyki said:

Hi,

Article written respectable. It has helped me a lot.

Thanks

# April 13, 2008 12:33 PM

Zakłady Bukmacherskie said:

Very good job. Very good info. Do it.

# April 23, 2008 3:15 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker