|
Hello,
I am trying to create a server for a game engine. Right now when a client connects to the server I create a new thread and a new Connection object for the client. The connection object listens for any data being sent from the client and somehow has to pass back the data to the server.
Client ---> Server ---> Connection
This is where I am stuck. I want to create a wrapper class for the server which causes me to rethink my design.
Right now the Connection object has a event which is fired when data is received from the client. The server also has an event for when data is received from the client. The connection object fires the servers event which in turn lets the wrapper class know data has be received.
Connection
----------
Event dataReceived
Server
----------
Event dataReceived
Connection.dataReceived += foo(DataReceived)
public void DataReceived(foo e)
{
dataReceived(this, e)
}
Wrapper
----------
Server.dataReceived += foo(DataReceived)
public void DataReceived(foo e)
{
}
I find this difficult to explain so I hope I was clear enough. I would appreciate any help regarding this subject. Is it even wise to create a new object for each client connection? etc..
ANY HELP would be extremely appreciated
Thanks, Thomas Hoggard
Thomas Hoggard
|
|
|
|
|
How to implement cut/paste etc. edit and toolstrip menus if Windows forms contains DatagridView.
to reproduce:
Observed:
first column is not empty
Expected:
first column must be empty
Code to reproduce:
using System.Windows.Forms;
using System.Data;
static class Program {
static void Main() {
Application.Run(new Frm());
}
}
class Frm : Form {
public Frm() {
DataGridView dataGrid1 = new DataGridView();
DataTable t = new DataTable();
t.Columns.Add();
t.Columns.Add();
t.Rows.Add("111111", "222222");
dataGrid1.DataSource = t;
dataGrid1.Dock = DockStyle.Fill;
Controls.Add(dataGrid1);
}
protected override void OnActivated(System.EventArgs e) {
base.OnActivated(e);
Control o = ActiveForm;
while (o is ContainerControl) {
ContainerControl oContainer = (ContainerControl)o;
o = oContainer.ActiveControl;
}
if (o != null && o is TextBox)
((TextBox)o).Cut();
SendKeys.SendWait("{TAB}");
}
}
Andrus
|
|
|
|
|
2. TabPage control without page captions
I have C# .NET 1.1 Winforms appication.
I use Toolstrip buttons to select pages in TabPage Control.
To save window space, I need to remove page captions.
Pages should appear without caption in Tab control.
I set tabpage Text properties to empty strings but empty page captions
are still present.
How to remove tab captions from TabPage pages ?
Andrus
|
|
|
|
|
Hello,
I think it would be easier to remove the TabPage from the TabPages Collection, hold the instance, and if you whant to show it, add it again.
All the best,
Martin
|
|
|
|
|
It works fine with C# .NET 2.0, but are you sure that it is not only that you has not redrawn the form? It might be an .Invalidate() call missing. Have you tried changing them in run-time to other strings? If empty strings does not work, try using one-space strings instead " ", might give you similar result.
Internet - the worlds biggest dictionary
|
|
|
|
|
Is there a way to get notified when the active document changes?
So far I've managed to subscribe on the DocumentOpened and the DocumentClosing events, however I did not find any way to know when the active document changed. My addin should be enabled only when the forms designer is viewed, and I would therefore liek to disable it when other documents are viewed.
Anyone got any hint for me?
|
|
|
|
|
Hi,
i have a problem with a WebBrowser-Control on my Form.
I navigate to a Webpage, which is broader than the width of the Form/WebBrowser-Control.
I have Scrollbars enabled but it doesn't show the horizontal Scrollbar.
But iIn the InternetExplorer it shows the Scrollbar.
Can sb help me?
greets
el_MKay
|
|
|
|
|
I trust there is quite a difference between an elementary browser component and a full-
fledged application such as Internet Explorer.
Have you read this recent article[^] ?
Luc Pattyn
|
|
|
|
|
Hi people,
I am running a DOS batch file (.bat) from inside a C# code. I am using the Process class to do that. The problem I have is weird, it seems that on the dev machine, the process is firing the event too quickly (i.e. it is not even executing) and since the call is supposed to create a file on disk, the file of course is not found. On the other hand, on a normal (client) machine, it seems to work, but i'm not sure that it works all the time.
Could anyone give me some solution to this weird problem?
Thanks,
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Are you calling the process synchronously or asynchronously? An asynchronous call returns immediately without waiting for the process to finish executing.
---
Year happy = new Year(2007);
|
|
|
|
|
hi,
thanks for the quick reply. well as a matter of fact, I'm calling it asynchronously, I am using the event p.Exited += new EventHandler(Ended) to perform some processing once the command line process has terminated.
Thanks,
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi All
I want to know if there is any useful links that can help in building a hardware simulator using C#, if you know a place where I can get information, plz help
thx
|
|
|
|
|
By "hardware simulator", I assume you're talking about digital circuits. If so, are you referring to a generic simulator (that can model at the gate level) or are you interested in simulating a simple CPU?
This[^] Wikipedia article provides a high-level overview of HDL if you're looking at gate level simulation. If you're looking to simulate a simple CPU, send me email and I may be able to offer you some hints offline. (My thesis was a simulator for a 1K RAM CPU).
Cheers,
/ravi
|
|
|
|
|
Hi ravi
thx for your quick response,
I am interested here in simulating a many simple CPU's that works in parallel, you can think of it as multi processors
|
|
|
|
|
Hi all. I have three columns in Table say A , B , C. The datatype of all columns is BIT . At a time, only one value can be true. like
A B C
true false false
false true true
Now, in gridview, I want to show that if the value of column A is true, it has to show some image else no image.
Please tell me how to do that. I will be very thankful to you.
Thanks for your anticipation.
|
|
|
|
|
Hello,
I would like to ask you about tool, which can generate documentation for projects in .NET 2.0 based on XML documentation files.
I know only an unofficial version of NDoc with support for .NET 2.0.
http://jonas.lagerblad.com/blog/?p=4
Maybe you know alternative to this tool?
Thanks in advance
cyberjoe
|
|
|
|
|
Take a look at the following article here on CP: Sandcastle Help File Builder[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello all
is there any method to bind the thread name property of the thread class with the id property of the processThread class.
my application create more than one thread bt i cant keep track of them as i cant map the id with the name
Please Help
MiNa
|
|
|
|
|
I had been looking for this too, and did not find anything.
Threads do have a name, but we programmers have no control over it.
The .NET doc says the name of a System.Thread can be set once, if that is also
true for the underlying Win32 thread object, then I am afraid .NET gives it the
name "Thread" and we can't do anything about it.
Luc Pattyn
|
|
|
|
|
Thanks,
I was trying to assign an id to each thread by getting the last thread id added to the processThreadCollection directly after starting the thread to ensure that this ID belong to the just started thread.
and then i can track the thread wether they are running or not and knowing the state of them,
but this solution is risky as the number assigned may be wrong.
Any other suggestions ?
MiNa
|
|
|
|
|
Some ideas:
1)
Inside your app you could attach a name to your thread by using a hash table;
that could help keeping track of things, but it only lives inside your app.
External tools for watching processes, threads and other resources (such as TaskInfo)
would not know about it of course.
2)
When your app contains logging, you could add a thread identification, based on ID
or attached name, or whatever (always starting with Thread.CurrentThread).
If your threading situation gets complex, you really should do this.
3)
whatever you come up with, some threads will not follow your scheme, e.g.
Threadpool threads, Backgroundworkers, etc.
But I avoid these, since you dont have full control over them (set priority, kill, ...).
4)
I tend to use my own thread class that holds a thread and a descriptive text, but also a
mechanism to report progress and a means to cancel/kill/abort
(I started doing this before NET 2.0, so before Backgroundworkers were available).
Luc Pattyn
|
|
|
|
|
how do i can keep track the threads using hash table ?
i want to know the state of the thread i created.
and all the info about the threads in the processThreadCollection is the ID
and actually i dont know which thread has this ID
Thanks again for your help
MiNa
|
|
|
|
|
Hi,
the following is not correct, it gives the ideas, first for .NET 1.1 then 2.0
with .NET 1.1:
when you create a thread, insert it in a hashtable
Thread thread=new Thread(...);
threadHash.Add(thread, "Searching database");
thread.Start();
you can now list all your threads:
foreach (DictionaryEntry de in treadHash) {
string descr=(string)de.Value;
Thread thread=(Thread)de.Key;
...show the thread, its ID, its state and descr
}
the only caveat is: doing this keeps all thread objects alive, since they are all in
the hashtable, so you should try to throw away the ones you dont need anymore,
either with threadHash.Remove() when a thread comes to an end,
or by periodically checking the thread states.
with .NET 2.0:
when you create a thread, insert it in a hashtable
Thread thread=new Thread(...);
threadHash.Add(thread.ManagedThreadID, "Searching database");
thread.Start();
you can now list all your threads using
foreach (Thread thread in processThreadCollection) {
string descr=threadHash[thread.ID];
...show the thread, its ID, its state and descr
}
Since you are not holding a collection of thread, there is no cleanup problem.
Luc Pattyn
|
|
|
|
|
Plz refere.........
System.Monitor class
Protecting Code by Using the Monitor Class
The System.Monitor class enables you to serialize the access to blocks of code by means of locks and signals. For example, you have a method that updates a database and that cannot be executed by two or more threads at the same time. If the work being performed by this method is especially time-consuming and you have multiple threads, any of which might call this method, you could have a serious problem on your hands. This is where the Monitor class comes in.
Parwej Back...............DON of Developer.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Thanks
do you mean i have to lock the code that start the thread and gets the last added thread in the processThreadCollection to ensure that the number assigned to the thread is the correct number in the processThreadCollection ??
Thanks again
MiNa
|
|
|
|