RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Detect console close

pepolshet

Sorceror
Detect console close

I am developing a server with a thread for each player, how can I detect when the user has pressed the X button so I can free all the stuff and terminate all the threads?
 

deathwearer

Sorceror
Code:
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(ConsoleExit);
        }

        static void ConsoleExit(object sender, EventArgs e)
        {
            Console.WriteLine("Something");
        }
    }
}
 

Jeff

Lord
how many players do you plan on having??? One Thread per player is extremely poor design.
 

pepolshet

Sorceror
thx deathwearer.Jeff I'm making a MMORPG so more = better, why is one thread per player a poor design? This way I get support for any multi-core processor, but seeing you have a lot of server designing experience how would you make it?

EDIT: Also I'm trying to make ScriptCompiler.cs word on my server, where is the core class created? Is there a source of RunUo.exe?
 

deathwearer

Sorceror
Too many threads hurt perfomances. Also sharing data between threads can be a hassle.

You might want to google it, you will probably find plenty of resources on this subject.
 

pepolshet

Sorceror
The latest RunUO is running multi-thread or am I mistaken? (No thread per a player though) Also I got ScriptCompiler.cs working yey!
 

Lichtblitz

Sorceror
RunUO is not really multi-threaded. There is one main worker thread and one that manages the timers. That's basically it. Maybe I forgot one but there are never more than two or three threads running simultaneously for a long period in RunUO. Creating a complex system with a lot of threads is a huge task.
 

Jeff

Lord
You can only have 25 threads running consecutively per core... this is a poor design. RunUO doesnt even do this and it can host over 2000+ users concurrently.... RunUO uses 1 thread... I think your knowledge of threading is misconstrued. RunUO only multithreads saves, one thread to save items, one for everything else.
 

deathwearer

Sorceror
Not that I really want to burst your bubble, but judging by your programming knowledge, making a mmorpg doens't seems to be a very good idea. You could start by making a much smaller game and see how well it goes.
 

pepolshet

Sorceror
And what programming knowledge do you think I lack hm? So I didn't know RunUO isn't multi-thread that wont stop me from programming a MMORPG (especially because the client engine is finished)
 

Jeff

Lord
pepolshet;836562 said:
And what programming knowledge do you think I lack hm? So I didn't know RunUO isn't multi-thread that wont stop me from programming a MMORPG (especially because the client engine is finished)

Don't let him discourage you, the only way to learn is to do it, good luck.
 

deathwearer

Sorceror
Jeff;836564 said:
Don't let him discourage you, the only way to learn is to do it, good luck.

I'm not discouraging him, rather trying to push him in a better experience and learning tool than straight going for a mmorpg. I'v seen so many (cannot count them) people over gamedev asking for help for a mmorpg project and just quitting after they stuggle with a problem they cannot solve. It's a huge project with late visual rewarding of your efforts.

Maybe I overlooked your programming skills, hard to judge, but you seem to lack knowledge over threads which gives me an idea of where you might be.

As a word of advice, you will quickly find that google is your best friend. The console quit event was an easy one that you could have search. Not that I don't like to answer such question, but you will find your answer way faster and won't get frustrated because nobody answer you as fast as you want.
 

Jeff

Lord
Except who are you to tell someone not to try to make something they want to make? Let him try, if he fails and gives up, guess what, his choice... if he wants to learn, he will, if not, telling him to go learn C# before attempting this isn't going to make a difference.
 
Top