|
A 7 word question is of the same quality, so you'd get about the same answer.
|
|
|
|
|
rule #1 in "how to answer a question" really should be: always keep the answer as short as the question".
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
|
Press F5
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Wow. Just...Wow.
|
|
|
|
|
It must be Thursday... I never could get the hang of Thursdays.
|
|
|
|
|
|
Buy a book
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
delete
modified 2-Apr-21 5:24am.
|
|
|
|
|
Put each IP Search onto a separate thread.
Whatever you sdo though the network response time is likely to be the limiting factor.
|
|
|
|
|
IMO bad advice. Using a few threads will help, launching tens or hundreds will result in hitting a bottleneck or a deliberate limitation inside the TCP/IP stack.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
This is really bad advice. Did you know that your allocating 1MB of RAM PER THREAD you create and keep running?
I'd look at using the managed thread pool before I start launching threads by the hundreds.
|
|
|
|
|
how would you change the code that it scan it fast or what would you add everybody said an other solution!
|
|
|
|
|
I'd design it so that I'd have about 5 or 10 or so threads all pulling IP addresses from a queue. Each of these workers would get an IP address, do it's job, report back, and then go get another address. You do NOT create a new thread for each IP address.
|
|
|
|
|
Hi
I have two ObservableCollections of an UserDefined Class which have an ID Property ,now i want to maintain 1 ObservableCollection locally and get another ObservableCollection from the DataBase,After i get them in one place i want to Compare those 2 ObservableCollections and delete the ID's from the local ObservableCollections which are not present in the ObservableCollections which is latest one(from Database).can some one give me the code for achieving this functionality.....Thanks in Advance
|
|
|
|
|
ramk_chirra wrote: can some one give me the code for achieving this functionality.....
That's not really the way that the forums work. If you have code that doesn't work, we will try to help you fix it, we won't write it for you.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
ramk_chirra wrote: Compare those 2 ObservableCollections and delete the ID's from the local ObservableCollections which are not present in the ObservableCollections which is latest one(from Database)
Why don't you have only one collection and each time you clear it and fill with latest data from DB? This will avoid unnecessary looping and deletions from one collection.
|
|
|
|
|
I was wondering if anyone has run into this problem and gotten around it in any way. Currently I am performing a front end conversion from a VB6 GUI to C#. It is quite a big change and therefore we are performing this in stages. Now in this process we currently are using "Microsoft.VisualBasic.Compatibility.VB6" array objects at times eg.RadioButtonArray, CheckBoxArray, etc.
Now when using these, there is a "SetIndex" method that is used throughout the existing code and it seems that the designer does not like the idea of this method being called when EndInit has been called already. It essentially renders the designer useless and we get an error in the designer. What we currently do is in the "InitializeComponent" method we call only "BeginInit" on the various arrays, and then in the form constructor after "InitializeComponent" is called we have another method we created called "InitializeComponentArrays" which we call all methods needing to call "SetIndex" and then we call their "EndInit" methods. This allows designer to load everything fine until we make any adjustments to the designer. When this happens, the windows generated code inserts all the "EndInit" methods into the "InitializeComponent" method which causes the designer to crash, and I then need to go in and delete the lines that it has entered. It is quite annoying and I felt it was time to reach out and see if anyone else has any better resolutions.
Thanks everyone!
Dan
|
|
|
|
|
Two suggestions:
1. don't touch the code inside InitializeComponent(), it isn't your code, it is the Designer's. And the Designer will change it any time it feels like changing it.
2. forget about SetIndex. If you need to easily access one or all of your checkboxes (or any other type of Control), create a collection yourself, by storing the references into a List<CheckBox> or something similar after your constructor called InitializeComponent(). A list accepts an integer index, so you can easily access the n-th checkbox if that is what you need.
Alternatively you can enumerate all top-level Controls of a Form, and pick the one(s) you need, like so:
foreach(Control c in this.Controls) {
CheckBox cb=c as CheckBox;
if (cb!=null) {
}
}
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: foreach(Control c in this.Controls) {
CheckBox cb=c as CheckBox;
if (cb!=null) {
// now cb points to one of your checkboxes
}
}
This is where you can have the luxury of LINQ. How about
foreach (CheckBox checkbox in from Control c in this.Controls
where c.GetType() == typeof(CheckBox)
select c as CheckBox)
{
}
modified on Thursday, September 17, 2009 11:43 AM
|
|
|
|
|
This may all be true and beautiful, but it is not what the OP needs; he is struggling with old VB code and fiddling with InitializeComponent(), so lets stick to the essentials and postpone the unnecessary magic.
BTW: I don't think your and my code are equivalent, mine also matches CheckBox derivatives.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Thanks for the help! Our code is not the same Luc, but I see what you were trying to do so I am going to play with that. I can't thank you enough for the quick response! Thanks again!
Dan
|
|
|
|
|
My mistake. It should be CheckBox . Updated the post.
|
|
|
|
|
Well I know only objects are garbage collected, but please hear me out..
I have a class "serverClass" in my program.cs file in a project. All the members of this class are static, moreover the members of this class are DLLIMPORTS of an unmanaged Dll. This file also has the IDE generated "Program" class which has the Main() function that invokes the Form1 GUI i.e.; Application.Run(new Form1());
Now, I have the Form1.cs file with Form1 class that has buttons and listboxes. The Form1 class has the button events, etc, i have also created a couple of member functions in the Form1 class (startServer() and stopServer()). These functions call the static members of the "serverClass" from the program.cs file. But as I said earlier the serverClass is static class and hence I cannot create an instance to access its functions, instead I go serverClass.function1() (i.e.; className.memberFunction()), serverClass.function2(), etc.
I want to access the startServer() and stopServer() functions on the click of the buttons "Start" and "Stop" respectively. So in the click events of these buttons I call these functions.
The project compiles fine. When I run the application/form and click 'Start' button the startServer() function is called and the server runs fine as desired. But my problem is when I click the 'Stop' button and the stopServer() function is called, I get a runtime error "CallbackOnCollectedDelegate" on the line in the stopServer() function where I call a member of serverClass as serverClass.function2().
I might be wrong in the class structuring itself....I appreciate all the suggestions and ideas.
BTW all of the mentioned classes are in the same namespace.
|
|
|
|
|
Without seeing any code, all one can do is guess. Maybe you have some local variables inside your static methods, say a delegate inside serverClass.Start() which is passed to some unmanaged piece of code, and hence all managed references to it are lost, so the next time around the GC will throw it out?
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|