|
hi,
ArrayList impliments few interfaces like IList,ICollection,IEnumerable,ICloneable by default. Suppose if you want to compare
the element of arraylist you need to impliment IComparer interface. This contain one abstract method called Compare.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
azusakt wrote:
however, any fast way to check this ??
If you want fast lookups and have unique elements, I suggest you use a Hashtable instead
top secret xacc-ide 0.0.1
|
|
|
|
|
azusakt wrote:
I have 3 ArrayList, each of them stored some string color name, I want to ask how can I check any duplicated strings between them?
first off - why do you have 3 arraylist which seem to be related to eachother - wont 1 suffice?
azusakt wrote:
Ofcourse, I can load all strings from one arrayList, and then use ArrayList.Contains(string) to check. however, any fast way to check this ??
Can I only use ArrayList.Contains() to compare with other ArrayList directly?
you might consider changing your datastructure to something that provides constant time mechanisms.. an arraylist is basic - some of the operations performed on it - (i think ) are not necessarily constant time complexity. how about something that using a hashing function of some sort ? like for example if you were to have 3 hashtables you could simply do a containskey which is constant time on thme ...
you might want rethink what you are doing though - can you suffice with just 1 and then pass a reference to the remain parts of your program that require this datastructure?
Danny!
|
|
|
|
|
Hi,
I'm writing a C# windows forms application. I've a strange problem in this. Some times, I'm not able to close my appl in the following ways :
1. by clicking on the close button of the form.
2. by clicking on the tool bar button, which calls this.Close();
3. by clicking on the Close option on the menu which you get when you right click on the taskbar/application's icon.
In other words, the only way I could close the application is by terminating from the task manager. This makes me crazy. Please help me...
Cheers
CNU
|
|
|
|
|
Are you running any thread or anyother process in your form? Its seems your form is busy waiting for someother process to complete
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
I've some other threads running in my form. But in Form's Dispose method I stop the thread, if it is still running, close the database connection.
My application has some chid forms, which in turn may open some other child forms. But, before I close main form, all of them will be closed (bcoz, they are all Model forms).
|
|
|
|
|
hi,
Make sure whether you are not doing anything in OnClosing event of your form.
protected override void OnClosing(CancelEventArgs e)
{
try
{
DialogResult r;
r = MessageBox.Show("Do You Want To Close This Module?", "Quiting",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(r == DialogResult.No)
{
e.Cancel = true;
base.OnClosing (e);
}
else
{
e.Cancel = false;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
No, I am not doing any thing in OnClosing(). But what makes me crazy is everything else in the application works fine i.e. all the controls are responding as usual, I can open child forms etc. Only the appl cannot be closed.
|
|
|
|
|
hi,
Try to use Application.Exit() method for closing the application
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi,
If cnu is using somethred and it is not completed on the time of dispose then your will get a "Application Communication Error". Nothing else. So here we can't assume that this problem is because of thred.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Like the others, I also think you have a dangleling thread somewhere. Make sure the thread can exit exit properly from its loop, or use the ThreadPool for "fire and forget" threaded ops.
Best bet lies here: As soon as it happens, break the debugger and inspect all running threads (and make sure u name your threads!).
HTH
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi!
I've experienced a similar effect while experimenting with a docking framework and then, later, in one of my own programs as well.
IIRC, the effect was produced by removing a control from its parent form while this control had the focus.
I just tried it out, but can't reproduct the effect now. Might be due to .NET 1.1 or .NET 1.0 SP2 (I tried both runtime versions to no avail).
But I know the problem WAS in there because there still is a workaround in my code (an invisible button receiving focus (via this.ActiveControl=myButton) befor removal of child controls).
Are you removing controls at runtime?
mav
|
|
|
|
|
Yes...I add and remove controls at run time...
Is this the problem ?? So, if I unselect the control (just in case it has the focus) before removing, can it solve the problem?
Cheers
CNU
|
|
|
|
|
Most likely, yes.
Add an invisible button to your form and before calling myForm.Controls.Clear() or Remove() or RemoveAt() set the active control to this button: myForm.ActiveControl=invisButton .
I think this also is relevant when you're removing controls from panels on this form.
You can also try .NET Framework 1.0 ServicePack 2 or .NET 1.1.
mav
|
|
|
|
|
Hi,
anybody knows how to convert .pwi to image?
is there any component available?
thanks
|
|
|
|
|
|
Pocket Word files
|
|
|
|
|
khchan wrote:
Pocket Word files
Ahh, sorry, the best I can think of it to use a digital camera
top secret xacc-ide 0.0.1
|
|
|
|
|
Greetings CP!
Well - it appears I've been presented with a roadblock and cant seem to find the problem.
Heres the situatio.
Ive created an app that has to scann 16000+ servers - for now - all that has to be done is connect and send and receive once asynchronously.
I am able to get the entire process down - the problem that occurs is that at random times the app just halts.
It just stops connecting to the servers - no exceptions thrown - no nada. Its not a threading problem - unless its a bug in the threadpooling for asychronous socket communications.
To draw out some broad strokes about the current scenario
Classes
MainForm applications main form
ConnectionState stores connection information
- buffer
- socket
- server hostname
- start time / end time / elapsed time
ConnectionManager this object is used in the main form (connection
state is not accessed directly)
- i start the process with a method called
CheckServers() which is passed to a ThreadStart object
in the main form for a Thread object named worker
- the worker thread is started and is set to a
background thread from the main form
MessageEventHandler a delegate used to pass the messages from the buffer
to controls on the main form
I know this is a somewhat complicated issue to deal with over these forums.. but - i have traced every aspect of my code - 2-3 days spent in the debugger watching everything and still no luck.
Any suggestions?
Danny!
|
|
|
|
|
Are you setting off alarms at your ISP?
They may not like you accessing so many machines. It could be taken as a worm or a vulnerability test in preparation for a new virus etc.
|
|
|
|
|
Hrmmm you know what - i didnt think about that..
Maybe I should put a delay between requests - like a random delay to see if that stops the problem..
Good idea!
Anymore suggestions?
Danny!
|
|
|
|
|
Some how I dont think the .NET threadpool is gonna cut that
Some other suggestions:
- socket buffersizes and timeouts, by default they will wait for ever...
- Linger options
- Socket options (god knows what they all do....)
top secret xacc-ide 0.0.1
|
|
|
|
|
leppie wrote:
Some how I dont think the .NET threadpool is gonna cut that
Well instead of using thread pools manually im using them by means of asynchronous communication. to my understand - when communicating asynchronously with sockets (i.e. BeginConnect EndConnect etc etc ) these mechanisms use threadpooling in the background.
Now it all depends on how you use these mechanism. For example - my first attempts maxed out the thread pools and i was only able to do 25 connections and blah - it got stuck there. I was able to by pass this with creating only 1 object that would do the main communication. Originally i had created an object which handled the entire connection including buffer / socket as well as the async parts. but for some nutty reason - this method did not prove to work - possible because garbage colleciton - although it was manually called - would not collect the lingering objects which were ready for collection..
leppie wrote:
- socket buffersizes and timeouts, by default they will wait for ever...
when it comes to this - during asynchronous communications the appropriate exceptions are thrown informing you of these.
leppie wrote:
- Linger options
- Socket options (god knows what they all do....)
well alas you have me at this one. right now im not using any socket options - since it seems to be working quite well without them..
ending comments...
i took the first suggestion and implemented a random wait interval between each connection to each server. this proved to work perfectly - since that post the application has gone through 4000 servers and its still going - which is by far - further than its gone before. i simply put in a random interval between 1 and 30 seconds. although its a trade off for now - in time - the production system wont have these restrictions (i.e. flood control or worm detection whatever they call it )
Again thanks all for the advice and comments.
Also - any more suggestions?
p.s. a word on asynchronous sockets...
ive test various methods of socket communication - async, sycn, manual thread pooling, custom threading... everything.. ive been able to achieve equal results if not better with the manual threading in comparison to asyhc mechanisms - but it was far trickier to achieve.
has anyone implemented a server app - web server? ftp server? irc serveR? anything with async sockets in c#? just curious about your results..
Danny!
|
|
|
|
|
welp! it appears i spoke to soon - the app stopped working yet again - now its either my isp that keeps blocking or something else - i have resorted to fiddling with the socket options..
lets see if this works out..
Danny!
|
|
|
|
|
Danny Rodriguez wrote:
now its either my isp that keeps blocking or something else
Get a port sniffer/packet capture prog and see what happens! I suggest NGSniff + winpcap (only thing that didnt BSOD me).
I have a funny feeling something is wrong in the Sockets in .NET, other problems, but if there's one, there bound to be more!
I will look into those options and see what I can suggest. You definately want to turn lingering off.
Have you tried another threadpool implemeatation perhaps?
top secret xacc-ide 0.0.1
|
|
|
|