When I compile my web browser application...When I compile my web browser with an RSS reader as well as a browser
Page 1 of 1
5 Replies - 1621 Views - Last Post: 24 March 2009 - 01:09 PM
#1
When I compile my web browser application...
Posted 23 March 2009 - 03:06 PM
I have a simple RSS reader in a Web Browser application I am making. But whenever I click "Show RSS feeds" which makes my RSS reader window show, my application goes non-responsive!!!! VB 2008 isn't registering any errors or warnings! Help please!
Replies To: When I compile my web browser application...
#2
Re: When I compile my web browser application...
Posted 23 March 2009 - 03:17 PM
please post code, we can't find the problem without the source :-D
#3
Re: When I compile my web browser application...
Posted 23 March 2009 - 04:01 PM
Ok, i am now yeilding an error when trying to show the RSS reader form. Here it is:
The CLR has been unable to transition from COM context 0x209a20 to COM context 0x209b90 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Here is my code for the RSS reader:
This is the code to show the RSS reader form:
The CLR has been unable to transition from COM context 0x209a20 to COM context 0x209b90 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
Here is my code for the RSS reader:
Imports System.IO
Imports System
Imports System.Xml
Imports System.Net
Public Class FeedBrowser1
Dim webc As New WebClient
Dim RssURL As String
Dim Node As System.Xml.XmlNode
Dim objRSSItem As RSSItem
Public XmlDoc As New XmlDocument
Public TempDump As String
Public Null As Boolean
Dim OnClose As Boolean = False
Dim sValue As String
Public sPath As String = Application.StartupPath & "\Index.ini"
Dim SectionArray As String
Dim i As Integer = 0
Public Shared Title As String
Dim mine As Boolean = False
Dim Locationload As Boolean = True
Dim Errors(2) As String
Dim UpdateTime As Integer
Public Class RSSItem
Public Title As String
Public Link As String
Public Description As String
End Class
Private Sub FeedBrowser_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If OnClose <> True Then
If INIRead(Application.StartupPath & "\Config.ini", "Config", "OnExit", "Unknown") = "Prompt" Then
Select Case MsgBox("Are you sure you want to exit?", vbYesNo)
Case vbNo
e.Cancel = True
Exit Sub
Case vbYes
NotifyIcon1.Visible = False
If Me.WindowState = FormWindowState.Minimized Then
End If
End Select
ElseIf INIRead(Application.StartupPath & "\Config.ini", "Config", "OnExit", "Unknown") = "SysTray" Then
e.Cancel = True
NotifyIcon1.Visible = True
Me.Hide()
Exit Sub
End If
End If
NotifyIcon1.Visible = False
If Me.WindowState <> FormWindowState.Minimized Then INIWrite(Application.StartupPath & "\Config.ini", "Config", "WindowState", Me.WindowState.ToString)
End Sub
Public Function FolderExists(ByVal FolderPath As String) As Boolean
Dim f As New IO.DirectoryInfo(FolderPath)
Return f.Exists
End Function
Public Function FileExists(ByVal FileFullPath As String) As Boolean
Dim f As New IO.FileInfo(FileFullPath)
Return f.Exists
End Function
Public Sub FeedProperties()
Dim frm4 As New Feed_Properties
Feed_Properties.Owner = Me
Feed_Properties.Visible = True
End Sub
Public Sub EditFeed()
Dim frm3 As New Edit_Feed
Edit_Feed.Owner = Me
Edit_Feed.Visible = True
End Sub
Private Sub FeedBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If FolderExists(Application.StartupPath & "\XML") = False Then
Try
MkDir(Application.StartupPath & "\XML")
Catch ex As Exception
MsgBox("Critical error, could not create directory 'XML' in the installation directory " & vbCrLf & Application.StartupPath)
End Try
End If
Null = False
If INIRead(Application.StartupPath & "\Config.ini", "Config", "UpdateFeedsonload", "Unknown") = "1" Then
Dim Thread As New System.Threading.Thread(AddressOf UpdateFeeds)
Thread.IsBackground = True
Thread.Priority = Threading.ThreadPriority.Normal
Thread.Start()
Else
RefreshFeeds()
End If
RefreshCombo()
Null = True
Me.KeyPreview = True
UpdateTime = INIRead(Application.StartupPath & "\Config.ini", "Config", "CheckInterval", "Unknown")
If INIRead(Application.StartupPath & "\Config.ini", "Config", "WindowState", "Unknown") = "Maximized" Then
Me.WindowState = FormWindowState.Maximized
ElseIf INIRead(Application.StartupPath & "\Config.ini", "Config", "WindowState", "Unknown") = "Normal" Then
Me.WindowState = FormWindowState.Normal
End If
Try
Me.Location = New System.Drawing.Point(INIRead(Application.StartupPath & "\Config.ini", "Config", "X", "Unknown"), INIRead(Application.StartupPath & "\Config.ini", "Config", "Y", "Unknown"))
Catch
End Try
Locationload = False
End Sub
Private Sub FeedBrowser_Locationchanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Locationchanged
If Locationload = False And Me.WindowState = FormWindowState.Normal Or Me.WindowState = FormWindowState.Maximized Then
INIWrite(Application.StartupPath & "\Config.ini", "Config", "X", Me.Location.X.ToString)
INIWrite(Application.StartupPath & "\Config.ini", "Config", "Y", Me.Location.Y.ToString)
End If
End Sub
Private Delegate Sub UpdateFeedsDelegate()
Public Sub UpdateFeeds()
If Me.Label2.InvokeRequired Then
Me.Label2.Invoke(New MethodInvoker(AddressOf UpdateFeeds))
Exit Sub
Else
Errors(0) = ""
Errors(1) = ""
Errors(2) = ""
Dim MyDate As DateTime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second)
Me.Label2.Show()
i = 1
TempDump = ""
sValue = INIRead(sPath)
sValue = sValue.Replace("MadeGroups", "")
sValue = sValue.Replace(ControlChars.NullChar, "|"c)
Dim splitStrings As String() = sValue.Split(New Char() {"|"c})
Do Until splitStrings(i) = ""
sValue = INIRead(sPath, splitStrings(i), "Feed_Url", "Unknown")
Try
webc.DownloadFile(sValue, Application.StartupPath & "\XML\" & splitStrings(i) & ".xml.new")
Catch ex As Exception
Errors(0) = Errors(0) & splitStrings(i) & vbCrLf
End Try
Try
System.IO.File.Delete(Application.StartupPath & "\XML\" & splitStrings(i) & ".xml")
Catch ex As Exception
Errors(1) = Errors(1) & splitStrings(i) & vbCrLf
End Try
Try
System.IO.File.Move(Application.StartupPath & "\XML\" & splitStrings(i) & ".xml.new", Application.StartupPath & "\XML\" & splitStrings(i) & ".xml")
Catch ex As Exception
Errors(2) = Errors(2) & splitStrings(i) & vbCrLf
System.IO.File.Delete(Application.StartupPath & "\XML\" & splitStrings(i) & ".xml.new")
End Try
INIDelete(sPath, splitStrings(i), "Last_Check")
INIWrite(sPath, splitStrings(i), "Last_Check", MyDate)
Label2.Text = "Processed " & i + 1 & " feeds total."
Application.DoEvents()
i = i + 1
Loop
Label2.Text = "Completed."
RefreshFeeds()
If Errors(0) = "" And Errors(1) = "" And Errors(2) = "" Then
'MsgBox("Successully updated all feeds with zero errors", MsgBoxStyle.Information)
Else
If Errors(0) <> "" Then
TempDump = TempDump & "The following feeds failed to download: " & vbCrLf & Errors(0)
End If
If Errors(1) <> "" Then
TempDump = TempDump & "The following feeds failed to be deleted: " & vbCrLf & Errors(1)
End If
If Errors(2) <> "" Then
TempDump = TempDump & "The following feeds failed to be moved: " & vbCrLf & Errors(2)
End If
MsgBox(TempDump, MsgBoxStyle.Critical)
End If
Label2.Visible = False
End If
End Sub
Public Sub UpdateFeed()
Errors(0) = ""
Errors(1) = ""
Errors(2) = ""
Dim MyDate As DateTime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second)
Label2.Visible = True
i = 1
TempDump = ""
sValue = INIRead(sPath, Feeds.SelectedItem, "Feed_Url", "Unknown")
Try
webc.DownloadFile(sValue, Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml.new")
Catch ex As Exception
Errors(0) = Errors(0) & Feeds.SelectedItem & vbCrLf
End Try
Try
System.IO.File.Delete(Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml")
Catch ex As Exception
Errors(1) = Errors(1) & Feeds.SelectedItem & vbCrLf
End Try
Try
System.IO.File.Move(Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml.new", Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml")
Catch ex As Exception
Errors(2) = Errors(2) & Feeds.SelectedItem & vbCrLf
System.IO.File.Delete(Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml.new")
End Try
INIDelete(sPath, Feeds.SelectedItem, "Last_Check")
INIWrite(sPath, Feeds.SelectedItem, "Last_Check", MyDate)
Label2.Text = "Processed " & i + 1 & " feeds total."
Application.DoEvents()
i = i + 1
Label2.Text = "Completed."
RefreshFeeds()
If Errors(0) = "" And Errors(1) = "" And Errors(2) = "" Then
MsgBox("Successully updated all feeds with zero errors", MsgBoxStyle.Information)
Else
If Errors(0) <> "" Then
TempDump = TempDump & "The following feeds failed to download: " & vbCrLf & Errors(0)
End If
If Errors(1) <> "" Then
TempDump = TempDump & "The following feeds failed to be deleted: " & vbCrLf & Errors(1)
End If
If Errors(2) <> "" Then
TempDump = TempDump & "The following feeds failed to be moved: " & vbCrLf & Errors(2)
End If
MsgBox(TempDump, MsgBoxStyle.Critical)
End If
Label2.Visible = False
End Sub
Public Sub RefreshFeeds()
On Error Resume Next
Feeds.Items.Clear()
i = 1
sValue = INIRead(sPath)
sValue = sValue.Replace("MadeGroups", "")
sValue = sValue.Replace(ControlChars.NullChar, "|"c)
Dim splitStrings As String() = sValue.Split(New Char() {"|"c})
Do Until splitStrings(i) = Nothing
If ComboBox1.SelectedItem <> "All" Then
sValue = INIRead(sPath, splitStrings(i), "Group", "Unknown")
If sValue = ComboBox1.SelectedItem Then
Feeds.Items.Add(splitStrings(i))
End If
Else
Feeds.Items.Add(splitStrings(i))
End If
i = i + 1
Loop
Feeds.SetSelected(0, True)
End Sub
Public Sub RefreshCombo()
On Error Resume Next
ComboBox1.Items.Clear()
i = 0
sValue = INIRead(sPath, "MadeGroups")
sValue = sValue.Replace(ControlChars.NullChar, "|"c)
Dim splitStrings As String() = sValue.Split(New Char() {"|"c})
Do Until splitStrings(i) = Nothing
sValue = INIRead(sPath, "MadeGroups", splitStrings(i))
ComboBox1.Items.Add(sValue)
i = i + 1
Loop
ComboBox1.SelectedIndex = 0
End Sub
Private Sub FeedBrowser_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Minimized Then
If INIRead(Application.StartupPath & "\Config.ini", "Config", "OnMinimize", "Unknown") = "SysTray" Then
Me.Hide()
NotifyIcon1.Visible = True
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
Form2.Owner = Me
Form2.Visible = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
DeleteFeed()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
EditFeed()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
FeedProperties()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
NewGroup()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
EditGroup()
End Sub
Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
DeleteGroup()
End Sub
Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim Thread As New System.Threading.Thread(AddressOf UpdateFeeds)
Thread.IsBackground = True
Thread.Priority = Threading.ThreadPriority.Normal
Thread.Start()
End Sub
Public Sub NewGroup()
Dim frm5 As New New_Group
New_Group.Owner = Me
New_Group.Visible = True
End Sub
Public Sub EditGroup()
Dim frm6 As New Edit_Group
Edit_Group.Owner = Me
Edit_Group.Visible = True
TempDump = ComboBox1.SelectedIndex
End Sub
Public Sub DeleteGroup()
Dim frm7 As New Delete_Group
Delete_Group.Owner = Me
Delete_Group.Visible = True
End Sub
Public Sub DeleteFeed()
Select Case MsgBox("Are you sure you want to delete " & Feeds.SelectedItem & "?", vbYesNo)
Case vbYes
IniWriteable()
If Null = True Then
INIDelete(sPath, Feeds.SelectedItem)
Try
System.IO.File.Delete(Application.StartupPath & "\XML\" & Feeds.SelectedItem & ".xml")
Catch ex As Exception
MsgBox("Error deleting feed, XML file not found, or permission was denied", MsgBoxStyle.Critical)
Exit Sub
End Try
End If
End Select
RefreshFeeds()
End Sub
Public Sub AddFeed(ByVal RssLink As String, ByVal UserTitle As String, ByVal Group As String)
Try
XmlDoc.Load(RssLink)
Catch ex As Exception
MsgBox("Error loading XML document. Not a valid RSS feed?", MsgBoxStyle.Critical)
Exit Sub
End Try
IniWriteable()
If Null = True Then
Try
webc.DownloadFile(RssLink, Application.StartupPath & "\XML\" & Title & ".xml")
Catch ex As Exception
MsgBox("Error loading XML document. Not a valid RSS feed?" & Title)
Exit Sub
End Try
MsgBox("Added " & Title & " successfully!", MsgBoxStyle.Information)
Try
If Group = Nothing Then Group = "All"
INIWrite(sPath, Title, "Title", Title)
INIWrite(sPath, Title, "Feed_Url", RssLink)
INIWrite(sPath, Title, "Last_Check", File.GetLastWriteTime(Application.StartupPath & "\XML\" & Title & ".xml"))
INIWrite(sPath, Title, "Group", Group)
INIWrite(sPath, Title, "Publish_Date", XmlDoc.SelectSingleNode("rss/channel/pubDate").InnerText())
Catch ex As Exception
End Try
RefreshFeeds()
End If
Title = Nothing
UserTitle = Nothing
End Sub
Public Sub IniWriteable()
Try
Dim fs As New FileStream(Application.StartupPath & "\Index.ini", FileMode.Append, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.Close()
Catch ex As Exception
MsgBox("Could not write to index file because it's read only." & vbCrLf & Application.StartupPath & "\Index.ini", MsgBoxStyle.Critical)
Null = False
Exit Sub
End Try
Null = True
End Sub
Private Sub Feeds_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Feeds.SelectedIndexChanged
End Sub
End Class
This is the code to show the RSS reader form:
Private Sub ButtonX11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX11.Click FeedBrowser1.Show() End Sub
#4
Re: When I compile my web browser application...
Posted 23 March 2009 - 11:52 PM
Anyone got any ideas?
#5
Re: When I compile my web browser application...
Posted 24 March 2009 - 10:09 AM
I guess not, I'll try re-writing the RSS code to be incorperated directly in my browser, otherwise if no one has any ideas, I'll give up.
#6
Re: When I compile my web browser application...
Posted 24 March 2009 - 01:09 PM
step through the code and find out what is causing the error!
set a "break" on the load of the RSS then use the "step into" button to go through the code line by line.
this will show you exactly where the error is occuring!
set a "break" on the load of the RSS then use the "step into" button to go through the code line by line.
this will show you exactly where the error is occuring!
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|