|
yes. One, is file size, and i dont want the program to be loading all the stuff i dont need. File size saves time (downloading and running) and saving time means more users (most likley me and a bunch of friends) will want it to be fast, small, etc.
Would it be possible to grab the process and set it to hid somehow through that?
//Otis
|
|
|
|
|
OMG, this is my second time writing this, cause last time i wasnt logged in, and i clicked submit, and it said i needed to login, so i hit back to copy/paste my post into notepad, and it was gone... arrgh. Anyways:
I have a class, lets call it "IrcBot". Now, i instanciate it like this:
IrcBot mybot = new IrcBot("server","channel","nick");
now, in my main class, i make a thread (or 10) all going to the same, or different irc servers... like this:
Thread t = new Thread(new ThreadStart(mybot.connect));<br />
t.Start();
seeing as there is no way to terminate the connection from the bot to the irc server, i cant terminate the thread, cause the thread is still doing something... In english, when i do t.Abort(); it doesnt stop and the bot is still in the irc server in that channel... How can i force the thread to stop regardless of whether its doing something or not?
Thanks for the help :P
//Otis
|
|
|
|
|
What i did now, is i made an instance of a timer within my thread, and set the interval to 1 millisecond...
System.timers.timer t = new System.timers.timer(1);
Then i made the event handler thing
t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
and the elapsed method looks like this:
private void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />
{<br />
if(System.Threading.Thread.CurrentThread.ThreadState.Equals(System.Threading.ThreadState.AbortRequested))<br />
{<br />
connection.Disconnect("Gotta go!");<br />
} <br />
}
Why wont that terminate the connection & die when i call abort from the main thread?
//Otis
|
|
|
|
|
Well, i finally figured it out...
In the IrcBot class, i made the variable holding the connection public. Then, before i started the thread, i grabbed that connection, and stored it in a variable. Then when i want to abort the thread, i use the variable and disconnect, and then abort It is kinda crude, but it works
//Otis
|
|
|
|
|
What would you suggest as the easiest way of converting a stream to a string?
|
|
|
|
|
|
System.Web.UI.WebControls.Label myLabel = new System.Web.UI.WebControls.Label();
myLabel.Text = "Enter Client ID";
this.Controls.Add(myLabel);
This is not working .. any help..please
|
|
|
|
|
What do you mean by "doesn't work" (what kind of exception are you getting?). I believe you need to set other properties of the newly created label, such as location and size. I usually set the following and never have a problem:
Name
Location
Size
BackColor
ForeColor
Hope this helps
|
|
|
|
|
Hi Guys,
I want to port my old client-server programme from VB6 to C#, and I want to use some new stuff from the .NET Framework. Especially how the two programmes communicate with eachother.
Verbodrome (that is how the programme is called) is used in classrooms, for example 20 students are working on it, and the teacher can centrally view the state of each student. In VB6 this was done with a TCP/IP connection but since the server took a lot of processing load (serving 20 clients) it just wasn't scalable.
So what I want to do is this:
- An object 'session', wich stores the various questions. It is cloned for every client so the 'session' object also stores the answers the students gave.
It is hosted on the server with following advantages. 1) When the students quit their session, the information is still stored on the server, and next time they log on they can work further on their previous session, and the teacher can view the progress the student is making. 2) Every time the student gives a new answer, the statistics on the server screen are real-time updated (thats where the events come in).
There are various other objects in the project, but all with similair purposes. So i tried to get some basic programme up and running. I constructed a CAO server, wich could fire events to the remote machine (where they were handeled. First problem: CAO servers don't seem to work due to some SOAPSUDS.EXE bug , so i tried a class-factory (a SAO wich generates the necessary 'new session' classes), but when i tried fire my server event, the client gave an error that this wasn't deserialisable... So I adjusted the security settings (1.0 -> 1.1 troubles), but that either was no good.
So now I am asking the outside world, because I really tried everything. I'm a good programmer in VB6 (Verbodrome counts over 58.000 lines) but I am relatively new to C# but I know the basics. If anyone could give me a clue or try to get a class to work that would serve as an example to me, I would greatly appreciate it.
Every goodbye is the birth of a memory
|
|
|
|
|
Hi Guys,
I want to port my old client-server programme from VB6 to C#, and I want to use some new stuff from the .NET Framework. Especially how the two programmes communicate with eachother.
Verbodrome (that is how the programme is called) is used in classrooms, for example 20 students are working on it, and the teacher can centrally view the state of each student. In VB6 this was done with a TCP/IP connection but since the server took a lot of processing load (serving 20 clients) it just wasn't scalable.
So what I want to do is this:
- An object 'session', wich stores the various questions. It is cloned for every client so the 'session' object also stores the answers the students gave.
It is hosted on the server with following advantages. 1) When the students quit their session, the information is still stored on the server, and next time they log on they can work further on their previous session, and the teacher can view the progress the student is making. 2) Every time the student gives a new answer, the statistics on the server screen are real-time updated (thats where the events come in).
There are various other objects in the project, but all with similair purposes. So i tried to get some basic programme up and running. I constructed a CAO server, wich could fire events to the remote machine (where they were handeled. First problem: CAO servers don't seem to work due to some SOAPSUDS.EXE bug , so i tried a class-factory (a SAO wich generates the necessary 'new session' classes), but when i tried fire my server event, the client gave an error that this wasn't deserialisable... So I adjusted the security settings (1.0 -> 1.1 troubles), but that either was no good.
So now I am asking the outside world, because I really tried everything. I'm a good programmer in VB6 (Verbodrome counts over 58.000 lines) but I am relatively new to C# but I know the basics. If anyone could give me a clue or try to get a class to work that would serve as an example to me, I would greatly appreciate it.
Every goodbye is the birth of a memory
|
|
|
|
|
Creating double posts with in the same forum is frowned upon even when using a different login. People will probably just keep ignoring it until you delete the offending posts and re-phrase your question.
Regards,
Eric C. Tomlinson
P.S. Look at some of the articles here on Code Project for threads/threading. Some have the basics for making a threded chat server, which can be modified for communication between clients / server.
I won't dignify your question with an answer. Yes, I program in VB6, but only because I'm addicted to eating!
|
|
|
|
|
I double posted it because
- The first time 'The Code Project' website thought i wasn't logged in
- The (emot)icons didn't work: X|X| looks a bit strange...
And i can't delete the first question because I wasn't logged in so the system doens't know it's ... I can of course delete the second post, but thereby eliminating the reason why I posted it again
|
|
|
|
|
But on both posts your name or intials show up as the user name. How did you do that?
I won't dignify your question with an answer. Yes, I program in VB6, but only because I'm addicted to eating!
|
|
|
|
|
Hi,
Heath had mentioned using a Dataset.Merge for a returned dataset from web service to client but I can't seem to find any property called Merge.
Where do I find it ?
Thanks,
JJ
|
|
|
|
|
It's clearly there:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataSetClassMergeTopic2.asp
Are you sure you declared it as System.Data.Dataset? And not as a datatable or something like it?
|
|
|
|
|
Hi,
I need to test if an Array object is empty. What's the best way to do this? Also how do you determine if an object exists?
Thanks,
JJ
|
|
|
|
|
MrJJKoolJ wrote:
I need to test if an Array object is empty. What's the best way to do this?
Do you mean contains no elements, or that all the elements are null?
The Length property will tell you how many elements are in an array.
If you mean the second option then you would have to iterate over the array testing for null on each element.
MrJJKoolJ wrote:
Also how do you determine if an object exists?
I don't understand this at all. If an object exists you will have a reference to it somewhere. Although, sometime objects will exist that you don't have a reference to anymore and by that time it is too late because the garbage collector will be clearing it out soon anyway.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
That the array contains no elements. Also How do you test if all the elements are null?
On the object question, I need to know how to test if an object exists for a reference.
Thanks,
JJ
|
|
|
|
|
MrJJKoolJ wrote:
Also How do you test if all the elements are null?
bool allNull = true;
foreach(object element in myArray)
{
if (element != null)
{
allNull=false;
break;
}
}
At the end of this code snippit, allNull will be true if all the elements of the array are null. It will also be true if the array is of zero length (so you might need to test for that condition also)
MrJJKoolJ wrote:
On the object question, I need to know how to test if an object exists for a reference
Okay, a bit of confused terminology here. You want to tell if a "variable" references an object or not. For that, it looks like Otis_69 responded with the correct answer for that.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
To determine if the object exists you do this:
if(yourobject != null)<br />
{<br />
}<br />
else<br />
{<br />
}
I hope you have the right word (exists) because an object that doesnt exist is just a name. If it does exist, then it has a refrence to a location in memory that holds the object.
To test if the array is empty, do as the guy before me said, use yourarray.length() because by empty, i assume you mean the name exists, which holds a refrence to the object (so the object exists) but there is no data in the elements...
//Otis
|
|
|
|
|
|
no problem...
All these other people may be guru's, and thats why they dont understand that you want a simple answer... Where as i just learned that stuff a few weeks ago in college, and im new to C#, i can help you on a more "noob" level (no offense, if any)... Thats the problem with smart people and trying to help others, they think that we know a shitload of stuff, when they gotta think like the person they are helping... :P I've seen it happen too many times, id ask something, and a whole bunch of guru's will come along and say "do this, do that" and it gets so complicated, they seem to think im whining, when i just cant understand, and then they tell me i cant program C# anymore because i have to know everything... then a someone with just a bit more skill comes along, and tells me what to do... and im satisfied. I say that noone should ever ask a guru what might seem to be a simple question to them.
Well, thats just my little grudge, ill prolly get flamed for it, and called a whiner, when im just stating my opinion, with some facts :P I just ignore them :P
//Otis
|
|
|
|
|
If you want to determine if the elements of your Array reference an object of a class, you have to iterate over your Array and test them against null, like Colin said.
Alternatively, you could use an ArrayList instead of the Array. The ArrayList class provides the Count property which tells how many objects really exist in your ArrayList.
www.troschuetz.de
|
|
|
|
|
Is it possible to force an event to trigger in C#?
eg. I would like to trigger the Button2_click event every time the Button1_Click event is triggered, so as to execute BOTH the code of Button1_Click and Button2_Click.
.::YF::.
|
|
|
|
|
Register one event handler for both of them.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|