Click here to Skip to main content
15,914,795 members
Home / Discussions / C#
   

C#

 
GeneralRe: setup and unistall Pin
tomorrow_ft16-Sep-10 3:24
tomorrow_ft16-Sep-10 3:24 
GeneralRe: setup and unistall Pin
Calla16-Sep-10 3:31
Calla16-Sep-10 3:31 
QuestionEmbedding Dependancies in C# Excel Workbook Pin
Grimes14-Sep-10 23:33
Grimes14-Sep-10 23:33 
QuestionLarge ncb file in a C# project Pin
Bernhard Hiller14-Sep-10 22:14
Bernhard Hiller14-Sep-10 22:14 
AnswerRe: Large ncb file in a C# project Pin
_AnsHUMAN_ 14-Sep-10 22:18
_AnsHUMAN_ 14-Sep-10 22:18 
GeneralRe: Large ncb file in a C# project Pin
Bernhard Hiller15-Sep-10 2:09
Bernhard Hiller15-Sep-10 2:09 
AnswerRe: Large ncb file in a C# project Pin
fjdiewornncalwe16-Sep-10 2:06
professionalfjdiewornncalwe16-Sep-10 2:06 
QuestionThread and Webbrowser Control- Want to Create webbrowser on the fly(runtime) Pin
yogeshcgs14-Sep-10 20:34
yogeshcgs14-Sep-10 20:34 
Dear All!!!

I want to create webbrowser control at runtime. for this i created one class to handle runtime created webbrowser. meantime i will be calling this class in threads, might be 10 threads at a time.

I made one class where i am creating webbrowser control. and i have made properties and events to handle this browser.

if i call this without thread, its ok.

But i want to call this class in thread. i tried but the document completed event does not get fired in this class.

see the code...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebBrowserExample
{
public class Class1
{
public WebBrowser Browser=new WebBrowser();
public delegate void DocumentCompletedDelegate(string DocumentText);
public event DocumentCompletedDelegate DocumentCompletedEvent;
public Class1()
{
Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted);
}
public void NavigateUrl(string Url)
{
Browser.Navigate(Url);
}
public string DocumentText
{
get;
set;
}
void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (Browser.ReadyState == WebBrowserReadyState.Complete&&Browser.Document!=null)
{
DocumentText = Browser.DocumentText;
if (DocumentCompletedEvent != null)
{
DocumentCompletedEvent(DocumentText);
}
}
}
}
}


I am calling this class through form ..


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WebBrowserExample
{
public partial class Form1 : Form
{
Class1 class1;
Thread BrowserThread;
public Form1()
{
InitializeComponent();
class1 = new Class1();
class1.DocumentCompletedEvent += new Class1.DocumentCompletedDelegate(Class1_DocumentCompletedEvent);
}

void Class1_DocumentCompletedEvent(string DocumentText)
{
webBrowser1.DocumentText = class1.DocumentText;
}

private void button1_Click(object sender, EventArgs e)
{
BrowserThread = new Thread(StartBrowsing);
BrowserThread.SetApartmentState(ApartmentState.STA);
BrowserThread.Start();
}
void StartBrowsing()
{
class1.NavigateUrl("http://codeproject.com");
}
}
}

in this form there is webbrowser control so when class's browser gets completed the form's webbrowser document text should be updated.

Any idea will be appreciated .

Thanks!
AnswerRe: Thread and Webbrowser Control- Want to Create webbrowser on the fly(runtime) Pin
Dave Kreskowiak15-Sep-10 2:16
mveDave Kreskowiak15-Sep-10 2:16 
AnswerRe: Thread and Webbrowser Control- Want to Create webbrowser on the fly(runtime) Pin
Pete O'Hanlon15-Sep-10 3:45
mvePete O'Hanlon15-Sep-10 3:45 
Questionc# Pin
solanki12314-Sep-10 20:03
solanki12314-Sep-10 20:03 
AnswerRe: c# Pin
Dave Kreskowiak14-Sep-10 20:04
mveDave Kreskowiak14-Sep-10 20:04 
AnswerRe: c# Pin
Abhinav S14-Sep-10 20:24
Abhinav S14-Sep-10 20:24 
AnswerRe: c# Pin
Dave Kreskowiak15-Sep-10 2:12
mveDave Kreskowiak15-Sep-10 2:12 
AnswerRe: c# Pin
PIEBALDconsult15-Sep-10 3:06
mvePIEBALDconsult15-Sep-10 3:06 
Questionencoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 10:00
stephen.darling14-Sep-10 10:00 
AnswerRe: encoding and decoding in BASE 10 Pin
Ennis Ray Lynch, Jr.14-Sep-10 10:11
Ennis Ray Lynch, Jr.14-Sep-10 10:11 
AnswerRe: encoding and decoding in BASE 10 [modified] Pin
Luc Pattyn14-Sep-10 10:18
sitebuilderLuc Pattyn14-Sep-10 10:18 
GeneralRe: encoding and decoding in BASE 10 Pin
harold aptroot14-Sep-10 10:23
harold aptroot14-Sep-10 10:23 
GeneralRe: encoding and decoding in BASE 10 Pin
Luc Pattyn14-Sep-10 10:24
sitebuilderLuc Pattyn14-Sep-10 10:24 
AnswerRe: encoding and decoding in BASE 10 Pin
T M Gray14-Sep-10 10:21
T M Gray14-Sep-10 10:21 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 10:55
stephen.darling14-Sep-10 10:55 
GeneralRe: encoding and decoding in BASE 10 Pin
AspDotNetDev14-Sep-10 11:22
protectorAspDotNetDev14-Sep-10 11:22 
GeneralRe: encoding and decoding in BASE 10 Pin
stephen.darling14-Sep-10 12:11
stephen.darling14-Sep-10 12:11 
GeneralRe: encoding and decoding in BASE 10 Pin
T M Gray14-Sep-10 12:17
T M Gray14-Sep-10 12:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.