|
No!
I really got a problem which tortured me for two days.
What I really want is to settle my problem but never hope others can do job for me.
I had post my problem before this page with title "Error 1784 when invoke SetupDiGetDeviceInterfaceDetail in c#".I see you must a super man,so can you help me out of this problem?
Thanks!
Best Regards!
momer
|
|
|
|
|
momer wrote:
data type of chat*
I'm assuming it's char* , so you might try using Marshal.PtrToStringAuto ?
there are no facts, only interpretations
|
|
|
|
|
......
char* charpoint;
string string1 = Marshal.PtrToStringAuto(charpoint);
It says that char* can not convert to IntPtr.
Thanks!
|
|
|
|
|
What are you trying to do exactly? i thought you where trying to convert a char* u got from some unmanaged source. You should try:
char ch = 'x';
char* charpoint = &ch ;
IntPtr pChar = new IntPtr(charpoint);
string string1 = Marshal.PtrToStringAuto(pChar);
there are no facts, only interpretations
|
|
|
|
|
Hi!yoaz,
Thank you very much I get it.
Thanks you again.
God bless you!
momer
|
|
|
|
|
Hey!
I have a Server/Client program.
The client is sending 4 packages to the Server and the server echo this pacakges back to the client that calculate the time and loose of packages.
I use UDP blocking Connection and threds, like this
byte[] data = new byte[64*1024];<br />
IPAddress addr = Dns.GetHostByName(this.GUI.txtIPAdr.Text).AddressList[0];<br />
dest = new IPEndPoint(addr,int.Parse(this.GUI.txtPort.Text));<br />
iend = dest;<br />
<br />
for(int i = 0; i<4;i++)<br />
{<br />
<br />
this.GUI.lblStatus.Text = "Sending";<br />
<br />
Thread Reciving = new Thread(new ThreadStart(ReciveMessage));<br />
<br />
data = Encoding.Unicode.GetBytes(this.GUI.txtMessage.Text + " " + i.ToString() + " to " + dest.ToString());<br />
<br />
interval = DateTime.Now;<br />
client.SendTo(data,(EndPoint)dest);<br />
Reciving.Start();<br />
<br />
Thread.Sleep(2000);<br />
<br />
if(Reciving.IsAlive)<br />
{<br />
Reciving.Abort();<br />
}<br />
<br />
}<br />
this.GUI.lblStatus.Text = "Stopt";<br />
client.Close();<br />
this.GUI.button1.Enabled = true;
in the ReciveMessage i use
client.ReceiveFrom(data,ref end);
The problem it, if the second packages is lost, then the rest will also be lost, i think that the thread that is running the Recive function the second turn(when there is no answare from the server) is looking then blockt client.ReceiveFrom and there by the other threads cant use this function to get teh pending echo from Server.
Shold i remake to nonBlocking mode? or is there a way to use the Threads better?
The best is if i could close a Thread when the time is finish(thread.sleep(2000)) but Reciving.abort() is not always removed instantly by the garbage collector.
I need the Thread to releas the resurces it got so other threads can use it.
//Jimmy
|
|
|
|
|
Why are you using blocking mode?
And why are you using UDP-Datagrams?
You should rather be sending ICMP-Messages, like "ping" does.
And drop the counter from your "Send-And-Receive"-Loop, you do not know how many replies you will get. That should be in a seperate "send-Thread", if anyhwere.
And yes, I'd rather be using non-blocking socket methods, there is much more flexibility in there.
Oh, and use "Thread.Abort(); Thread.Join();".
Cheers
Sid
|
|
|
|
|
does anyone know how to explain ann's in programming terms since i get natural nn's but not ann's
IM PROUD TO BE A GMAIL;
|
|
|
|
|
there's a series of articles here, starting with this one[^]
there are no facts, only interpretations
|
|
|
|
|
Hi,
I am trying to use a class in multiple projects. It is a simple class containing properties of a given database table. The class, DbTable, is defined in my main DbCompare project. I also want to use this class in a Control Library (UserControl) project which will itself be used in the DbCompare project. However, I am in circular reference hell! When I build the DbCompare project, I get the warning 'DbCompare.DbTable' is defined in multiple places; using definition from 'D:\Proj_net\DbCompare\DbTable.cs'. Does anyone know how to do this?
TIA,
Royce
|
|
|
|
|
If you can re-architect your application I would suggest using events to avoid the circular references.
If you have a layered approach like this:
Presentation
----------------
Business Logic
----------------
Data Abstraction
The Presentation can invoke methods directly in the Business Logic layer, and the Business Logic layer can do the same to the Data Abstraction layer.
However the Data Abstraction layer should know nothing of the Business Logic layer, and the Business Logic layer should know nothing of the Presentation layer.
Think about how the .NET Framework achieves this. The guys at Microsoft know nothing of your application, so the controls fire off events in order to pass messages to your code.
So, If the Data Abstraction layer needs to invoke something in the Business Logic layer it should fire off an event that something in the Business Logic layer subscribes to. Similarly with the Business Logic layer needing to invoke something in the Presentation layer.
Does this help?
Do you want to know more?
|
|
|
|
|
Thanks, Colin.
Yes, I think you have given me some useful ideas.
|
|
|
|
|
hi,
i am taking a network corse in college, my prof. ask for a simulator for a telecomunication network , such that 2 guys talk to another one but not in the same time ; if person A is talking with C the B is on Hold.
any 1 can help ?
"the problem that i don't know how to use graphics in c#"
I realy need Help
|
|
|
|
|
you don't have to, just use a console version or use symbolism, or even switch off pictures
IM PROUD TO BE A GMAIL;
|
|
|
|
|
hi,
thanx 4 ur replay, but i think I didn't get ur point
|
|
|
|
|
improvise;P
IM PROUD TO BE A GMAIL;
|
|
|
|
|
Sakkijha wrote:
"the problem that i don't know how to use graphics in c#"
The other poster is suggesting you don't need to use graphics. I tend to agree - you'll be marked on how well your simulator works, not how pretty it is.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
For some reason, as simple as this seems, I'm having trouble getting it working. My scenario:
I have one dll that I want shared by two exes. What I want to happen, is EXE1 will make a call into the DLL, and in that function call the DLL will raise an event that will be caught in EXE2. what I have done is in both EXE1 and EXE2 project, I have referenced the same DLL. When EXE2 loads up, it registers the dll event, and when EXE1 calls that function in the DLL that fires that event, registered by EXE2, it doesn't work because the event is null. So the event was never registered. Is this because both EXEs are using their own copy of the DLL, and not REALLY sharing the same DLL? How can I achieve the behavior desired?
thanks
|
|
|
|
|
vista27 wrote:
Is this because both EXEs are using their own copy of the DLL, and not REALLY sharing the same DLL?
Although DLLs allow you to share the same code between two applications the data isn't shared. Hence the event fired in one EXE is not picked up by the other EXE.
vista27 wrote:
How can I achieve the behavior desired?
I have to admit never having needed to do this. The closest I've ever got is a web application making a change in a database and a Service process checking the database periodically to see if there is any new data. The event of the web application is picked up in the service which is a similar scenario, but the service spends most of its time asleep and only polls the database once a minute.
How soon does the event need to be picked up? If a wait of a minute is acceptable then something similar to my previous solution may work for you also.
Although I have not used it, Message Queues may be what you are looking for. MSMQ - Overview[^]. C#: A Message Queuing Service Application[^]
Do you want to know more?
|
|
|
|
|
To add to waht Colin said, you can't share a .DLL like this between two .EXE's because, like he said, the data is no shored between processes. The .DLL doesn't run in it's own process. It's injected into the process that's using it, therefore each .EXE has seperate instances of the data for the same .DLL.
Using a .DLL, you can't get the functionality you want. You'll have to rewrite the .DLL and code it to use the singleton pattern and pass data back and forth through remoting. There is no way to adapt the .DLL to your requirements.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Does anyone know how if its possible to tell what software a server is running (i.e. Apache, etc) using a HttpWebRequest as a starting point? I'd like to be able to get the current server time as well, if possible. Couldn't find an example in the MSDN library - any ideas, suggestions?
Thanks,
Justin
|
|
|
|
|
Can anyone tell me what kind of form this - http://people.clemson.edu/~jegarri/box.gif - is? I would like to have something similar, with the categories at the top, but I can't find anything like it in the Windows forms available in VS.Net 2003.
Thanks,
Justin
|
|
|
|
|
|
Terrific, I completely missed that one, thanks Tom.
Thanks,
Justin
|
|
|
|