Create a multi threaded web browsing application. : Thread « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Windows Presentation Foundation » ThreadScreenshots 
Create a multi threaded web browsing application.
  

<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" Height="600" Width="800" Loaded="OnLoaded">
  <StackPanel Name="Stack" Orientation="Vertical">
    <StackPanel Orientation="Horizontal">
      <Button Content="New Window" Click="NewWindowHandler" />
      <TextBox Name="newLocation" Width="500" />
      <Button Content="GO!" Click="Browse" />
    </StackPanel>
    <Frame Name="placeHolder" Width="800" Height="550"></Frame>
  </StackPanel>
</Window>
//File:Window.xaml.cs

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Threading;
using System.Threading;

namespace WpfApplication1
{
    public partial class Window1 : Window
    {
        public Window1() : base()
        {
            InitializeComponent();
        }

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
           placeHolder.Source = new Uri("http://www.java2java.com");
        }

        private void Browse(object sender, RoutedEventArgs e)
        {
            placeHolder.Source = new Uri(newLocation.Text);
        }
        private void NewWindowHandler(object sender, RoutedEventArgs e)
        {       
            Thread newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint));
            newWindowThread.SetApartmentState(ApartmentState.STA);
            newWindowThread.IsBackground = true;
            newWindowThread.Start();
        }
        private void ThreadStartingPoint()
        {
            Window1 tempWindow = new Window1();
            tempWindow.Show();       
            System.Windows.Threading.Dispatcher.Run();
        }
    }
}

   
    
  
Related examples in the same category
1.WPF ThreadingWPF Threading
2.Thread Sleep in Button Click handlerThread Sleep in Button Click handler
3.Check Whether You Are Running on the UI ThreadCheck Whether You Are Running on the UI Thread
4.Ensure That You Are Running on the UI ThreadEnsure That You Are Running on the UI Thread
5.Execute a Method Asynchronously Using the Dispatcher QueueExecute a Method Asynchronously Using the Dispatcher Queue
6.ThreadPool.QueueUserWorkItemThreadPool.QueueUserWorkItem
7.BlockThread.xamlBlockThread.xaml
8.Keep the UI from becoming non-responsive in single threaded application which performs a long operation.Keep the UI from becoming non-responsive in single threaded application which performs a long operation.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.