|
Thanks you Judah Himango. I've visited this web already but i didn't find any thing in it regarding C#.Net. And I also contacted with the company but I thought may be some person try this device, so i posted question on it, anyways, thank you for liking my name.
Take Care & Allah Hafiz (Good Bye)
Butt
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
I read Worker Threads in C# by Alex F, and it seemed to be just what I needed, but I am ignorant enough in C# to have problems and I am desparate enough to repost my question on the main forum for help.
Basically, I have a windows form that takes a bunch of user input and goes off to run a lengthy simulation. I wanted to move the simulation to a separate thread to allow for an abort or pause control on the form, but still be able to post updates back to a box in the form.
I used the nifty Visual C# Express tools to make the form, so the form is partial classes split in two files, by default, the partial class is set to inherit from Form in the designer file, but if I understand how partial classes work it shouldn't matter where that goes. Other than this, I'm pretty sure I have crammed Alex's code into mine correctly. but...
In the class for the process to run on the worker thread, Alex uses
m_form.Invoke(m_form.m_DelegateAddString, new Object[] {s});
I'm not sure what m_form is (or how it relates to MainForm) I know this is some fairly standard example naming convention but I can't figure it out, and I frankly can't figure out anything with the Invoke method available. I've tried just reading about Invoke, but it just left me more confused.
I tried to get the thing to compile just leaving the meat of the long process out, but I get an No overload error with this line
longProcess = new LongProcess(m_EventStopThread, m_EventThreadStopped, this);
I assume because I am missing those parts in the LongProcess Run method.
I'm hoping that someone reading this is familiar with this article (but wouldn't have seen my plea there), and can help.
Unfortunately, I have to present this little project tomorrow with or without the thread , and the thread would be so much more professional...
Thanks in advance,
Ashley
|
|
|
|
|
Ashley,
I recommend you look at the BackgroundWorker[^] component found in .NET v2 and higher. It abstracts away all the invoking stuff for you, thus you don't have to worry about putting things on the right thread; the BackgroundWorker will do it for you. It will raise a DoWork event which will be fired on the background thread. When that's finished, it will raise a RunWorkerCompleted event fired on the UI thread. The article above discusses this in detail.
|
|
|
|
|
I've had a look at the demo app by Alex in his guid to worker threads,
here's what I can see and hopefully it will cast some light on what is wrong.
First m_form is defined within the file LongProcess.cs as
<br />
MainForm m_form;<br />
It is set when the function
<br />
longProcess = new LongProcess(m_EventStopThread, m_EventThreadStopped, this);<br />
is called from MainForm.cs - here 'this' is the MainForm in question. He just stores that instance in 'm_form', that way he can then 'Invoke" things on the MainForm thread later within the Run method in longprocess.cs.
As for why
<br />
longProcess = new LongProcess(m_EventStopThread, m_EventThreadStopped, this);<br />
is causing a compiler problem on your code - my belief would be that you have altered the code somehow so that it no longer acceps THREE parameters, or maybe you have changed the name of your form to be Form1 (which would be the default), if that is the case you need to change the parameter of the Form expected in longprocess.cs in the LongProcess method to be Form1 and not MainForm as in Alex's code.
Hope this helps get you started and good luck with the presentation....
Mark.
|
|
|
|
|
Thanks so much for taking the time to help!!!
Between my post and yours I had finally thought to download the demo (I actually hadn't realized there was a download with this article) and found the problems. I was actually missing all the Members and the LongProcess function from my LongProcess class (so my overload message was because of using a default constructor). Everything is working great now. Back on the article thread I've added an update as well.
As a general note to you super members reading this post:
First, Thank you for all your wonderful articles (saves me hours!!!)
However, I am not a downloader by nature. I think if the two missing elements had been in the sample code, even a beginner/non-downloader could get this going without help. When possible, keep the code samples pretty free standing.
Thanks again,
Ashley
|
|
|
|
|
Hi!
I want to open a user specified URL from C# code, i am using C# 2005. Can any body tell me how will i do it?
Thanks,
Regards,
Affan Ahmad Toor
|
|
|
|
|
use
System.Diagnostics.Process.Start("http://www.google.com");
put your URL in place of google.com
Enjoy
Anuj
|
|
|
|
|
Thanks for reply,
Your suggestion solved my problem but created another problem...
i am storing the user defined URL in XML file..
if i store the URL "http://www.google.com" it works perfectly, but when i try to store the URL "http://www.google.com/search?hl=en&q=abc" it corrupts the XML file and gives error "A semi colon character was expected."
can you tell me what is the reason behind this error...?
Thanks,
Regards,
Affan Ahmad Toor
|
|
|
|
|
|
No that was just a example...and yes try to understand requirement!
"I want to open a user specified URL from C# code"...
Anuj
|
|
|
|
|
Actually, the class I was thinking of was WebRequest[^]. That will allow you to make a request into any URI, including a user-specified URL.
|
|
|
|
|
pls send me the code anyone
|
|
|
|
|
can someone send me the code to create a Simulation that does 'The Beer Game'and The Beer Distribution Game (Beer Game) is a simulation game created by a group of professors at MIT Sloan School of Management in early 1960's to demonstrate a number of key principles of supply chain management.
rabie
|
|
|
|
|
moh_rabie wrote: can someone send me the code to create a Simulation that does 'The Beer Game'and The Beer Distribution Game
Sure, why don't we do a swap. You send me the code for the insurance claims application and I'll send you the code for the Beer Game.
|
|
|
|
|
thanx man but i don't have so if you can help me in this simulation send to me please
rabie
|
|
|
|
|
I think my sense of humour passed you by.
If you don't have the source for an insurance claims application, why would I (or anyone else here) have the code for "The Beer Game"?
|
|
|
|
|
he is talking seriously
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Or, he is the master of ironic answers!
|
|
|
|
|
|
lets go to the soapbox
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
|
|
I'd love to help you. But I, along with everyone else here, can help on specific things. We can't really help when it comes to source code for entire systems. It is a little beyond the medium of a forum.
If you want to make an attempt yourself at implementing your software and if you have a specific problem with part of it then we can most likely help you out. That is what forums are best for.
|
|
|
|
|
|
Sorry... I already have Tic Tac Toe...
|
|
|
|
|