|
here is a bubble sort for you...
for (i=0; i<n-1; i++)="" {
="" for="" (j="0;" j<n-1-i;="" j++)
="" if="" (a[j+1]="" <="" a[j])="" {="" *="" compare="" the="" two="" neighbors=""
="" tmp="a[j];" swap="" a[j]="" and="" a[j+1]="" }
}
=""
<div="" class="ForumSig">The Devil Lives in all of us, It's up to you to let HIM/HER out!!!!!
|
|
|
|
|
Hi,
sorting a DataGridView is no different than sorting any other collection:
- they have a Sort() method that applies a default sort order
- they have a Sort(IComparer) method that takes an object capable of
comparing two objects of the type you want to get sorted.
So read up on IComparer, and provide a little class that inherits from it.
The world must be full of examples of this.
|
|
|
|
|
Hi All,
I want to pass a vector from a C++ DLL to a .Net Client, can any one help me on how do i Marshal a vector using Pinvoke, I dint found any article related to this on the net.
The vector i want to pass is a vector of user defined structures
Regards,
Subodh
|
|
|
|
|
Calling all Crystal Report Gurus
I have this strange error coming up in one of my reports.
"One or more fields could not be found in the result set. Use verify Database to update report. Error in file ---------------- . the rowset column could not be found."
this is one of the last reports in my app and the delivery is delayed on account of this error.
There doesn't seem to be any apparent reason for this error.
Let me give you guys the background
1. I am using Visual studio 2005 and the CR verson which comes bundled with it.
2. I am using a CR viewer and the report source is an Reportdocument object
3. I have a record selection formula
as follows
if {?ClientSelect} = 'All' then true else {InvoiceSaleAnalysis;1.ClientID}={?ClientID}
I am setting the values of the above params thru front end code
When I view the report with 'All' (default it shows ok. However when i select a particular ClientID and change the param and refresh the report it gives me the above error the first time and when i refresh it again the required report is displayed
any ideas would be of help
Romi
|
|
|
|
|
Hi all.
I have created an application which access a send and receive method written in a class
now the problem which i am facing is strange when i call the recieve method of udp client object , and then if i want to stop the code of my application, it is not closing properly..when i checked ,,i found that recieve method of udp client creates all the problem.is there any way to play around..or any one can help me where i can found a good code for receiving...the main thing is that recieve method of udpclient should be always be listening...it should be in continous loop..
pls help me..
Regards
DilipRam
|
|
|
|
|
I had a similar situation not too long ago. To solve the problem I used the following snippet in a separate thread; to close the port just set UDPrunning to false, wait for the thread to exit and then you can close the port. I'm not sure if it's the best solution, but it is a solution that worked in my situation.
while (UDPrunning == true)
{
if (udpSocket.Available > 0)
{
try
{
IPEndPoint msgSenderInfo = new IPEndPoint(IPAddress.Any, 0);
Byte[] incomingData = udpSocket.Receive(ref msgSenderInfo);
}
catch (SocketException e)
{
}
}
else
{
Thread.Sleep(100);
}
}
|
|
|
|
|
Hi thanks for the reply
But i have doubt regarding one of ur suggestions.
You comment was
"to close the port just set UDPrunning to false, wait for the thread to exit and then you can close the port"
here the variable UDP running i have set to false in the close event of my application.and after seting the variable i am closing the port..is this the what you meant...if it is then no problem but i got confused that you were speaking abt the wait for the thread how should i wait for thread..
can you pls explain.
Regards
DilipRam
|
|
|
|
|
That's exactly what I meant! To stop listening all you have to so is set that var to false and continue on your way.
The comment about waiting for the thread is because I was running that method in a separate Thread from the gui thread. When I was shutting down my gui I wanted to make sure that the listener thread exited so that it wouldn't hang up my application. The Thread.Join() method waits for a thread to exit, so my socket shutdown code looked like this:
UDPrunning = false;
udpSocketThread.Join();
udpSocket.Close();
|
|
|
|
|
Hi,
I would not like a Join in my closing code, it might sit and wait forever.
Isnt the essence of the problem that you want the UDP listener thread to be
a background thread, one that does not prevent your app from exiting ?
|
|
|
|
|
Hi
can you bit clear please as i am new this socket programming and any way i am calling the receive method in a thread...
Regards
DilipRam
|
|
|
|
|
That essentially was the idea but there are 2 reasons that I didn't set udpSocketThread.IsBackground = true; and forget about it:
1) The worker function is coded to avoid a blocking situation where the thread would hang so I wasn't worried about it waiting forever and
2) I didn't previously know about the Background vs. Foreground Thread property. That's a pretty nifty Property to have, thanks for the info!
|
|
|
|
|
Yes, but my point is when the listener is in its Receive() method, it needs
another packet to resume its course, and only after that it could exit the loop,
so your Join() is actually waiting for another UDP packet to arrive (which
may never happen).
|
|
|
|
|
In my situation I wasn't worried about the Ethernet cable being pulled. It was just a little test app connecting to a server on the local machine as a proof-of-concept of another piece of code. That's why I said in my original post "I'm not sure if it's the best solution, but it is a solution that worked in my situation."
Using IsBackground would have been a wiser choice had I known about it.
|
|
|
|
|
Thanks for the reply..
just want to confirm that the join method will not get into any hang mode.
because i am calling the stop method by creating a object of dll and i dont have a thread in my application but the thread is present in dll where i have written the recieve method...
Regards
DilipRam
|
|
|
|
|
See my reply to Lucs post. I just found this[^] article explaining background vs. foreground threads, so apparently if you set udpSocketThread.IsBackground = true; then you won't ever have to worry about Joining the thread.
|
|
|
|
|
Thanks again and sorry for troubling again.just to ensure
that instead of doing UdpListnerThread.Join(); in my stop method
i need to set udpSocketThread.IsBackground = true.is that it means
thanks
Regards
DilipRam
|
|
|
|
|
That's how I would do it anyway.
|
|
|
|
|
Thanks for replies..finally my stop method will be having the following code
since i am using two udps and thread name is
udpManagerbroadCast.Close();///..udp
UdpListnerThread.IsBackground = true;///..thread
FlagVal = true;///flag value
soUdp.Close();///..udp
and hope this is what you all were suggesting.Hope this fit the standards which you were suggesting
Regards
DilipRam
|
|
|
|
|
|
Hello everyone,
I'm searching for a solution to a relatively small design specification that has turned into a big hassle. Data is loaded into each ComboBox from an XML file on a network. In the XML file, default values are specified for each ComboBox. I need to change the background color of the choice that is specified as the default -- that is, when the default is selected, it's background should change to a light-blue color, and the color should also appear when it is dropped-down and not currently selected.
Setting the BackColor makes it so every item is colored during the drop-down, and not just the default row. I read a CP article about a super-combo-box with font coloring for specific items (with a multitude of superfluous features), but for this application that is like killing a fly with a hand-grenade.
Does anyone have any simple suggestions or recommendations for this "simple" problem?
Thanks in advance,
Phil
|
|
|
|
|
|
Hi Vasudevan,
Could you please point me towards the Windows Form equivalent -- if one exists?
Thank you,
Phil
|
|
|
|
|
Hi,
ComboBox and ListBox share some characteristics:
1.
they collect and display items that dont have to be strings; it can be any type
you choose. So you can create your own little class that holds whatever is
appropriate to represent the info for that item; then you provide a ToString()
method to deliver the display string.
2.
they support a DrawMode property; when set to one of the UserDraw values,
it is up to your program to draw each individual item (in the DrawItem event)
any way you like.
Combining both points can be very powerful !
|
|
|
|
|
Hi Luc,
Thanks a lot, this looks very promising!
-Phil
|
|
|
|
|