|
For value types the lifetime is the entire method where it's declared, but the scope might be smaller, for instance inside a loop. Outside the scope, the room allocated on the stack for the variable is simply unused.
For reference types the lifetime is from when the object is created until it's garbage collected. When all references to the object go out of scope (or rather the lifetime ends, I believe), it can be garbage collected.
---
b { font-weight: normal; }
|
|
|
|
|
I have a MDI parent form with a main menu. I need to catch the click event in the child form and depending on the checked state of the menu Item in the main menu do some actions.
How can i do this?
Denis
|
|
|
|
|
You can hook the Click event of a menu item on the MDI parent form via the MdiParent property on the child form. It then exposes the Menu property, which is the MainMenu on the MDI parent.
private void MDIChildForm_Load(object sender, System.EventArgs e)
{
this.MdiParent.Menu.MenuItems[0].MenuItems[0].Click += new EventHandler(MDIParentMenuItem_Click);
}
private void MDIParentMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show( "Hello" );
}
In the Click event handler, cast sender to a MenuItem to inspect the Checked property of the item that was clicked.
Josh
-- modified at 11:26 Monday 24th April, 2006
|
|
|
|
|
Thanks a lot.
But I have some trouble. Although the MDIparent property is set in the parent form as follows:
newMDIChild.MdiParent = this;
for the code:
this.MdiParent.Menu...
i got the message: "Object reference not set..."
and in the watch window i see that the MDIparent property has the value undefined.
|
|
|
|
|
As far as I understand that happens when i use this line:
this.MdiParent.Menu.MenuItems[0].MenuItems[0].Click += new EventHandler(MDIParentMenuItem_Click);
not in the MDIChildForm_Load method.
But do you know why the MDIparent value is then undefined?
I got the message "Object reference not set..." when I used the line:
this.MdiParent.Menu.MenuItems[0].MenuItems[0].Click += new EventHandler(MDIParentMenuItem_Click);
in the constructor of the child form.
|
|
|
|
|
Oh, I see. If you are accessing the MdiParent property in the child form's constructor, then the parent form would not have yet had a chance to set the MdiParent property on the child. Try attaching your event handlers in the ChildForm's Load event handler. At that point the MdiParent will have been specified by the parent.
Josh
|
|
|
|
|
Hmmm...that's odd. Without seeing the code, I can't help any further.
Josh
|
|
|
|
|
Hi community!
I've created a simple test application to test data transfer rates when spooling files via remoting and get very strange results.
The client can either fetch a file from the server by calling a remote method
int ReadBuffer(int transferID, ref byte[] buf); until the file has been spooled completely or upload a file to the server by calling the remote method
void WriteBuffer(int transferID, int len, byte[] buf); until all blocks have been tranferred.
Basically what you have to do to spool a file in one direction or the other - can't get any easier, can it?
When I try this in a LAN environment, transfer is as fast as one would expect, but when used over the internet, the results are completely different.
One PC (client) has an ADSL connection: 3072kbit/s download, 384kbit/s upload, the other one (server) has a 2Mbit line up- and downstream.
I had expected the real transfer rates to reflect the asymmetric transfer rates, but upload AND download give me about 30KB/sec, although download should be a lot faster.
The weird thing is:
When I run the server program on the client PC and the client program on the server PC, then the transfer rate server PC -> client PC is up to 74KB/sec!
Copying files with Explorer is as fast as one would expect: ~35KB/sec upload and ~107KB/sec download...
Has someone experienced something similar and knows what the reason could be - or even better - what can I do to get the maximum transfer rates?
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Are you doing any synchronous updates to your UI after reading the buffer? Make sure your reading thread is doing reading only, delegating any other work to other threads.
How many bytes are you transferring per-call? The fewer the bytes, the more calls required, the more overhead, the slower the speed. This would be more apparent in a WAN environment.
mav.northwind wrote: int ReadBuffer(int transferID, ref byte[] buf);
Is that your exact code? I know that some remoting channels don't allow ref and out parameters. Typically when I do things like this, I prefer streams. But that's just a comment, shouldn't have anything to do with your speed problem, I can't imagine.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Is Jesus the Jewish Messiah?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Thanks for your reply, Judah!
The test program isn't doing any UI updates at all while the transfer is in progress, so that can't be the reason.
I've also tried different block sizes, ranging from 4KB to 256KB. Larger blocks give a little performance increase, but only a few percent - what one would expect if you take the usual remoting overhead into consideration.
I've tried with an out byte[] , but the result was the same. All these results come from a TCP channel with a binary formatter, btw.
I even tried getting the FileStream from the remote server object and then read the bytes directly from this Stream, but to no avail. The download is always slow, even slower than the upload, although the upload bandwidth is approx. 10 times smaller than the download bandwidth.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
|
Seems I've found a workaround, at least.
Instead of using ref byte[] or out byte[] I've tried using byte[] as method return value. This requires a little array copying but gives full speed to the caller.
By adjusting the maximum buffer size I was able to get transfer rates very close to what you can achive when copying a file with Explorer.
Nevertheless, I don't understand why the framework has such poor performance with out or ref byte[] parameters...
But thanks for taking your time!
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hi guys,
I would like an exe without any GUI, no forms, no consoles except when I'm in debug mode.
I've tried with using this.Visible = false (true respectively), but it doesn't work. (windows app template) I've also looked into the properties, but couldn't find it (class library template).
Is it possible to have an exe without a GUI?
tnx!
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
V. wrote: Is it possible to have an exe without a GUI?
Yes.
In the Main() method of your application you'll see a line like this:
Application.Run(new SomeFormClass()); Remove that line and the GUI won't get started.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I should 've thought of that one; although in this case the other solution better fits my needs.
tnx!
Coulda, woulda, shoulda doesn't matter if you don't.
-- modified at 9:01 Monday 24th April, 2006
|
|
|
|
|
I'm curious as to why you only want a GUI in debug mode. It sounds like you are using this as some sort of testing harness. If so, would it not be better to create some repeatable unit tests instead?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
No, We have a core application here at work, where you can plug in other programs. The developers before me, just added an exe for each little Change request, creating a directory full of exe's. If you click one, without the core application started, it will start the application empty (that's not the idea)
I'm making some start to clean up things. One is that I only use 1 exe that will load the appropriate program (In time to be recompiled as dll's, I hope). If no arguments are passed to the exe the GUI will show with an explanation, but if the arguments passed are correct, the user just sees the little program executed, nothing else.
It was the cleanest solution I could think off for the moment .
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
this worked for me in the OnLoad of a form;
this.ShowInTaskbar = false;<br />
this.Opacity = 0;
|
|
|
|
|
thanks I can use this one...
Coulda, woulda, shoulda doesn't matter if you don't.
|
|
|
|
|
please send me a code in c# that allows some IDE tools to click and drag. e.g. textbox,listbox,combobox...etc...
thanks....
|
|
|
|
|
There's three events you need to handle to do this. It's called drag and drop, if you use that terminology, I'm sure google has the details.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
hey howzit.
I am looking for a component that can extract information about fields in a PDF. e.g. their height, width, location etc.
PDF fields are used in electronic forms and are becoming quite popular.
I am looking for a component which is of reasonable price or freeware.
|
|
|
|
|
Hi,
I have a ListView control holding more than 3000 items (which means sorting can take a while). Therefore, I want to display a message saying "Sorting list" while the list is being sorted. The problem is I don't know how to tell when the sorting process has completed.
Any suggestions?
|
|
|
|
|
You might be able to create a thread to sort the items and once that thread has finished then you can say that sorting has finished. You may run into a few problems because I think that using multiple threads to update UIs is messy, your best bet might be to disable the ListView first thus ensuring that the user can't change anything inside it.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|