|
Ok, a couple things I'd check: verify the HtmlParser is created on the same thread you're doing the parsing/navigating on. Also, if a background thread is indeed creating the HtmlParser, verify that thread's apartment state is STAThread.
|
|
|
|
|
Judah Himango wrote: Ok, a couple things I'd check: verify the HtmlParser is created on the same thread you're doing the parsing/navigating on. Also, if a background thread is indeed creating the HtmlParser, verify that thread's apartment state is STAThread.
<br />
Thread worker = new Thread(new ParameterizedThreadStart(LoadHtml));<br />
worker.SetApartmentState(ApartmentState.STA);<br />
worker.Start(files);<br />
...<br />
<br />
private void LoadHtml(object obj)<br />
{<br />
foreach(FileInfo fileinfo in (FileInfo[])obj)<br />
{<br />
HtmlParser parser = new HtmlParser(fileinfo);<br />
m_listHtmlParsers.Add(parser);<br />
}<br />
}<br />
<br />
I think this is doing both of your suggestions? Any other ideas?
|
|
|
|
|
IIRC, the WebBrowser control needs to be visible in order to have it's events fired. Try adding the HTML control to a form, make it visible, then try navigating. I recall some bug or something with that where it has to be visible before the Navigated et al events get fired.
|
|
|
|
|
Judah Himango wrote: IIRC, the WebBrowser control needs to be visible in order to have it's events fired. Try adding the HTML control to a form, make it visible, then try navigating. I recall some bug or something with that where it has to be visible before the Navigated et al events get fired.
I'll give that a try, but the thing is, it works not being visible or in a form if it's in the main thread.
|
|
|
|
|
jbrower1 wrote: I'll give that a try, but the thing is, it works not being visible or in a form if it's in the main thread.
That doesn't work either... The same thing happens
|
|
|
|
|
Where does the parsing occur there? Upon construction? Or do you need to .Navigate or something?
|
|
|
|
|
I have a sample code for client server application : But could not able to send the request. Can anybody help me out to correct it?
This is the server code:
class MoneyServer
{
ArrayList talk = new ArrayList();
public MoneyServer()
{
talk.Add("A penny saved is too small, make it a buck");
talk.Add("Keep your wooden nickel. It will be worth something someday");
talk.Add("It's your dime, but u r a better if dialing 10-10-XXX.");
}
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
MoneyServer mSvr =new MoneyServer();
ASCIIEncoding ASCII = new ASCIIEncoding();
Byte[] inStream = new Byte[256];
Byte[] outStream = new byte[256];
Random rnd;
string reqString="";
int index;
string choice = "Q";
TcpListener tcpl = new TcpListener(2010);
tcpl.Start();
Console.WriteLine("Server is running...");
choice = Console.ReadLine();
Console.WriteLine();
do
{
try
{
choice = Console.ReadLine();
Console.WriteLine();
Socket sock = tcpl.AcceptSocket();
int count = sock.Receive(inStream,inStream.Length,0);
reqString = ASCII.GetString(inStream,0,inStream.Length);
Console.WriteLine("reqString = " + reqString);
rnd = new Random();
index = rnd.Next(mSvr.talk.Count);
//outStream = ASCII.GetBytes((string)mSvr.talk[index]);
outStream = ASCII.GetBytes(choice);
sock.Send(outStream, outStream.Length, 0);
}
catch(Exception ex)
{
Console.WriteLine("Generic exception message : {0}",ex.Message);
}
}while(reqString != "bye");
tcpl.Stop();
}
}
This is the client code:
class EnterpreneurialClient
{
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
ASCIIEncoding ASCII = new ASCIIEncoding();
Byte[] inStream = new Byte[256];
Byte[] outStream = new Byte[256];
string freeAdvice;
string choice = "Q";
do
{
try
{
Console.WriteLine("\nMoney Line\n");
Console.WriteLine("1 - Get Advice");
Console.WriteLine("Q - Quite");
Console.WriteLine("\nPlease Choose: ");
choice = Console.ReadLine();
Console.WriteLine();
TcpClient myClient = new TcpClient("localhost", 2010);
Stream myStream = myClient.GetStream();
outStream = ASCII.GetBytes("What is the secreat of making money?");
if(choice == "1")
{
//send request to server
myStream.Write(outStream,0,outStream.Length);
//clean garbage chars from byte array
for(int i=0; i
|
|
|
|
|
Hi,
Ive been playing with the culturalInfo example provided in MSDN, and although I understand it, I dont understand what need there is for it.
If I have the following code:
TextBox1.Text = DateTime.Now.ToString("D");
I still get the correct date format, whether my Windows Regional Settings are set to English or Hungarian.
So why do I need the CulturalInfo class?
Regards
Mark
|
|
|
|
|
Whenever a value is formatted or parsed in a way that can be culturally dependent, a CultureInfo or a FormatInfo object is used. Even if you don't specify one, one is used. Every time, without exception.
For an example, this statement:
TextBox1.Text = DateTime.Now.ToString("D");
is equivalent to:
TextBox1.Text = DateTime.Now.ToString("D", CultureInfo.CurrentCulture);
Sometimes you want the format to use the current culture of the user, but sometimes you want a specific format that is independent of the culture. For that you can specify a custom format, create a specific CultureInfo or FormatInfo object, or use CultureInfo.InvariantCulture.
---
b { font-weight: normal; }
|
|
|
|
|
Here is a concrete example:
We had an application that was crashing on one device but worked fine with all the others.
The problem was coming from the culture and the parsing of a string. All the devices were in english excepted the one that kept crashing who was a French Pocket PC french. When we did something like Double.Parse("2.00") it would crash on the french device because the decimal separator in that culture is a comma and not a dot...
|
|
|
|
|
Hi Monkey,
so what was the answer to this? How did you fix the statement Double.Parse("2.00") to be multicultural?
|
|
|
|
|
There is two solution to that particular problem:
-generate number according to the culture info (myDouble.ToString() does that). In that case the number is generated with the current culture and can be parsed with Double.Parse() because it's the same culture (the current culture)
- Double.Parse is surcharged, it has a version with a second parameter which specify how to parse it. I don't have visual studio right now so I can't tell what it is but you can look it up.
That makes ou feel very dumb when you find such bug : what I'm not even able to do such a basic thing as parsing number!?!
|
|
|
|
|
how can i exit event handler..and dont execute code in this event handler when some condition occurs
|
|
|
|
|
Use the return statement
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
if(Condition is true)
{
e.handle=true;
return ;
}
sameer
|
|
|
|
|
Please help me,
I have a final year project on Audio Video Logging System.
I basically want to do some motion detection, for which i have got some articles from CodeProject.com... this is the only small part of my Project
A big issue is that i want to do indexing on Video ie i want to do "Content Base Retrivel of Audio & Vedio Data"..
I have a server which always capturing Video in a office room, say, and store it in a database.... now if i want to do query on thoes store video, How can i do it.... Please help me.....
Any suggesstion will be appreciated.....
aLi
|
|
|
|
|
first we need to know how they are stored
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi,
How can i randomly add text in 50 labels at once instead of one at the time?
The labels are called:
label1
label2
label3
......
......
label50
Thanks in advance!
|
|
|
|
|
Wow, 50 labels, that must be one big form
Anyway, this should work:
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = "Hello";<br />
}<br />
}<br />
|
|
|
|
|
Hi The Undefeated,
Thank you very much for your reply!
Its going to be a calculation application for the kids
Instead of "Hello" how can i randomly give it sums like this:
2+6=
5+4=
....
....
Thanks in advance!
|
|
|
|
|
Hmm, you could do this then:
<br />
Random rnd = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
}<br />
}<br />
on the rnd.Next part, you have to set the minimum and maximum values (in this case 0 and 20)
If you wanted to include minus questions to could do this:
Random rnd = new Random();<br />
Random sign = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
switch(sign.Next(0, 2).ToString())<br />
{<br />
case "0": <br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
}<br />
break;<br />
<br />
case "1":<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
int large = rnd.Next(1, 20); <br />
int small = rnd.Next(0, 20);<br />
while(large < small)
{<br />
small = rnd.Next(0, 20);<br />
}<br />
<br />
label.Text = large + " - " + small + " =";<br />
}<br />
break;<br />
}<br />
}
And use a switch to change between + or -
-- modified at 9:30 Sunday 15th October, 2006
|
|
|
|
|
Hi,
Thank you for your reply!
The 0, 20 has to be random aswel. This is what i had in mind to do it:
int number1;
int number2;
int answer;
answer = number1 + number2;
The answer is a number which the application will get from a textbox. The user will give up a maximum number in the textbox.
Suppose the user types 100, than number1 + number2 = can never cross the 100.
Thanks in advance!
|
|
|
|
|
The (0, 20) cannot be random, and if it was it would be pointless.
int n1 = rnd.Next(0, 51);
int n2 = rnd.Next(0, 51);
n1+n2 would never be greater than 100, and the lowest would be 0, but the answer could be anything inbetween.
As for storing the answerm you can put it in the tag, and check it later
Random rnd = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
int n1 = rnd.Next(0, 20);<br />
int n2 = rnd.Next(0, 20);<br />
int answer = n1+n2;<br />
<br />
label.Tag = answer;<br />
label.Text = n1 + " + " + n2 + " =";<br />
}<br />
}<br />
You'd have to make sure that each text box was referencing the right label though, if you keep all the default names the textBox1 should reference label1
To get the answer back to check it simply:
int answer = (int)label1.Tag;
|
|
|
|
|
Hi The Undefeated,
Thanks for your reply!
I'll just make a few extra variables than
Thanks for your time and help The Undefeated!!!!!
|
|
|
|
|
The Undefeated,
How do i reference the textbox to the right labels?
|
|
|
|