|
thanks for the reference. I always saw BeginInvoke but didnt realise what it did till now.
|
|
|
|
|
I have an interesting problem that I am looking for some advice on. Basically I have a protocol library, where each PDU is a class. Thus the library is a collection of individual classes that are stateless.
Meanwhile, I have a need to aquire some housekeeping info via a one time register function. I'd like for this function to make the housekeeping info persistent or semi-persistent so that thet data would be available to the other classes as they are instantiated.
Now, I could use XML to write out persistant data but the overhead in file I/O seems quite underdesirable in a near real time application. I could write a value to the Registry, but again there is a performance hit. Finally I have considered kicking off a thread which the instantiated classes could interrogate but that feels over the top.
If only you could create a Shared Memory Region like the good ol' days (just kidding). But if you have tackled a similar problem, or know of an elegant approach please let me know. Thanks in advance!
Mike
|
|
|
|
|
mcljava wrote: PDU
What's a PDU?
If all this is happening in one application then reading an XML file at start up then holding the data internally isn't too bad. The other classes could then query the central housekeeping class. If it needs to write stuff out to persist it then it could do so when the application is shut down or at regular intervals so it doesn't disrupt the flow of the rest of the application.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
PDU usually refers to a Power Distribution Unit, used to switch between main power and backup generator power seamlessly with no loss of power.
|
|
|
|
|
Sorry for the confusion, PDU means Protocol Data Unit (i.e. a packet) in data communications and in my library.
|
|
|
|
|
I have a finished implementation for activation that relies on the manufacturer assigned non-changable serial number of a hard drive. During testing I discovered that my method of discovering this number does not work on all versions of Windows that are going to be supported. The WMI claass Win32_PhysicalMedia does not exist in Win2k. The workaround for this is also very painful, requiring DeviceIoControl and probably administrative priveleges at runtime. I noticed that there is Wmi32_BaseBoard class that provides a serial number. However, not all motherboard provide this information (driver code never sets the number).
What is a good, simply way to identify a machine that works consistently on Windows 2000 and newer?
Alex Korchemniy
|
|
|
|
|
Serial numbers are notorisouly unreliable. You might want to look into the machine SID. Search MSDN for it. I think it's the first 96 bits of the local admin account's SID.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello!
I am searching for a way to rearrange crossed-bounds text so that they don't appear on eachother. Your informations would be very helpful.
|
|
|
|
|
hi...
I have an exe compiled with VS and three references to 3 dlls within exe dir.
Is there a way to pack this dll and exe to have only one exe?And if there is... is a safe way?is there any possibility that anyone identify those packed dlls?
thanks
regards
|
|
|
|
|
|
thanks!!! is what I need!
thanks again
-- modified at 8:02 Friday 6th January, 2006
|
|
|
|
|
|
I'm implementing poor man's multithreading and need a way for a progress callback (delegate) to be able to pump the form's message queue so that it can check if the user has checked an "Abort" checkbox, thereby causing an ongoing computation to quit.
In Win32, we used to pump the GUI's message queue using PeekMessage() . What's the appropriate analog in the WinForms world?
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi Ravi
the analog call of PeekMessage is BeginnInvoke.
|
|
|
|
|
|
HI,
I am having a text file. I will be reading line by line from teh file. Can any one tell me how to move pointer from the current position to previous position(From the current line to previous line).
Example code i am using :-
StreamReader sr = File.OpenText(FILE_NAME);
String input="";
while ((input= sr.ReadLine())!=null)
{
String []strs = input.Split(';');
...
}
Can we move the sr to the previous line?
Plese let me know if there is another way handling the same
Thanks and Regards,
Subbu
|
|
|
|
|
Hi!
You'll have to use the Position property of the underlying Stream . Your sr has a property BaseStream you can use for this purpose.
Regards,
mav
|
|
|
|
|
Hi,
I am new to C#. I have a application with 10 winforms. But even after I close the app, the process still runs,ie, I could see the .exe still running in task manager.
how do I solve this. Thanks in advance.
|
|
|
|
|
Are you closing your main form ? If you're debugging, does the debugger maintain a connection ? Can you break and see where it's still running ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How do you close the app? Do you handle the Closing event yourself?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Here is what I do...
I have a main form called HomeForm. Another form called EnggHome has the exit button.
I call the EnggHome form HomeForm as
<br />
private void button3_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
EnggHome enggH = new EnggHome();<br />
enggH.Show(); <br />
this.Visible = false; <br />
<br />
}
In exit button code (in EnggHome)
<br />
private void button3_Click(object sender, System.EventArgs e)<br />
{ <br />
<br />
this.Dispose(true);<br />
this.Close();<br />
<br />
HomeForm Hom = new HomeForm();<br />
Hom.Dispose(); <br />
Hom.Close();<br />
<br />
}
In debug mode too, if I close the app using exit button, the debugger does'nt stops unless I stop it..
What am I missing???
|
|
|
|
|
I see some problems here: in the button3 handler, you instantiate a new instance of the MainForm. I suggest that you implement a constructor for EnggHome that takes a handle to the HomeForm parent form, and keep it among its private data members. In the button3 handler button for EnggForm, just call the HomeForm.Close() method.
public class EnggHome : Form
{
private Form _parentForm;
public EnggHome(Form parentForm)
{
this._parentForm = parentForm;
}
private void button3_Click(object sender, System.EventArgs e)
{
this.Dispose(true);
this.Close();
this._parentForm.Visible = true; <--- did you previously instantiate a new object to have you form reappear???
this._parentForm.Dispose();
this._parentForm.Close();
}
}
and in the HomeForm class method, when instantiating the EnggHome object:
private void button3_Click(object sender, System.EventArgs e)
{
EnggHome enggH = new EnggHome(this); <--- Notice the different constructor call.
enggH.Show();
this.Visible = false;
}
A more drastic approach would be to call Application.Exit(0) , but this would not give a chance to the parent form to clean up.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 16:55 Thursday 5th January, 2006
|
|
|
|
|
Thank you so much for ur reply. It works. But in my app I have like 10 forms. and in all the forms I have button called "Home" that calls the HomeForm using new HomeForm(). I navigate all the forms sequentially that say HomeForm is form1->EnggHome is form2->form3->form4...so on. So should I pass the homeform in the constructor of all the forms...or is there any other better way??
Thanks again.
|
|
|
|
|
Do you mean HomeForm creates EnggForm, which creates EnggForm, which creates EnggForm, etc. like a chain?
In this case, I suggest that each form has a handle to its parent, so you can navigate back.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Have you considered turning all your forms into controls, and hosting them all on the one form ?
Christian Graus - Microsoft MVP - C++
|
|
|
|