Multi Threaded Web Browsing WPF Application in VB.NET
In this article you will see how to create a multi threaded web browsing WPF application.
Now a days multi-threaded web browse applications become increasingly popular due to the advances of the Microsoft framework. Multi-threading is the ability for an application to perform more than one execution simultaneously. It can greatly improve the responsiveness and efficiency of an application.
Sample Code
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MultiBrowse Application" Height="600" Width="800" Loaded="OnLoaded">
<StackPanel Name="Stack" Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Content="New Window" Click="NewWindowHandler" FontSize="13" />
<TextBox Name="newLocation" Width="500" />
<Button Content="GO!" Click="Browse" FontSize="13" />
</StackPanel>
<Frame Name="placeHolder" Width="800" Height="550"></Frame>
</StackPanel>
</Window>
Vb Code
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Threading
Imports System.Threading
Namespace WpfApplication1
Partial Public Class Window1
Inherits Window
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Private Sub OnLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
placeHolder.Source = New Uri("http://www.vbdotnetheaven.com")
End Sub
Private Sub Browse(ByVal sender As Object, ByVal e As RoutedEventArgs)
placeHolder.Source = New Uri(newLocation.Text)
End Sub
Private Sub NewWindowHandler(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim newWindowThread As New Thread(New ThreadStart(AddressOfThreadStartingPoint))
newWindowThread.SetApartmentState(ApartmentState.STA)
newWindowThread.IsBackground = True
newWindowThread.Start()
End Sub
Private Sub ThreadStartingPoint()
Dim tempWindow As New Window1()
tempWindow.Show()
System.Windows.Threading.Dispatcher.Run()
End Sub
End Class
End Namespace
Output Window

Thats all about I am trying to explain you.