|
Sorry to say it so, but I don't know what this answer should help.
Both functions determine the same result.
And also both crash if Obj is null.
And finally here so funny text from MSDN:
"Caution:
The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method."
Sorry for the "downvoting", but your answer is simply wrong.
Greetings
Covean
|
|
|
|
|
Dear mate,
until this i taught the Equals method compare objects instances and the CompareTo method compare values.
I've search a little more and see that the Equals method for String is overriden to compare values.
In objects case the Equals method compare instances..
However the result is the same if you use CompareTo or Equals , so thanks for the tip!
Every day you learn something!
Cheer's,
Alex Manolescu
|
|
|
|
|
Hello Everybody........!
I've one problem. Please Help.
I have developed my project in VS2008. Noe it is to the final stage of completion. My All Crystal Reports are running properly.
The Only Problem I've is I need to run two crystal reports using single CrystalReportViewer.
So Please Tell me is it possible? If yes, How?
Thanks & Regards
Pankaj Patil
.
|
|
|
|
|
Hi Pankaj,
Using subreports you can do this.
1. You have alredy 2 reports like Test1.rpt and Test2.rpt OK.
2. Take onother Blank report like Main.rpt, [attach Test1.rpt SP or any], devide the details section like Details a & Details b --> for deviding detail section right click on Main.rpt -> select Sectiopn Extert -> select Details -> click on insert button
3.Then Click on sub report on top menu of the Main.rpt report --> Insert Subreport window is displaying -> select subreport tab -> choose existing report [Test1.rpt]with help of browse button - > Then select the Link tab -> set the parameter -> Click OK
4. one link is attached with cursor place it in Main.rpt Details a section
5. then repeate the step 3 for attaching Test2.rpt file -> place it in Details b section of the Main.rpt
6. In u r application cal the Main.rpt file instead of Test1.rpt
7. for allignment do some changes using Format Subreport [Righ click & select]
Thanks,
Basu Malipatil
|
|
|
|
|
Hi,
Anybody can help me to solve this problem.
I trying to open a powerpoint file(for preview) in my application using AxFramerControl.
axFramerControl1.Open(fileName, true, "PowerPoint.Show", null, null);
.....
.....
axFramerControl1.Close();
It is opening the file in my application, but after closing the file i am trying to delete the file.
File.Delete(filename);
In this case i am getting an error "Cannot delete access denied". i think it is problem with axFramerControl1.Close(), it is not closing the application properly. Can anybody tell me how to close the Framercontrol correctly to delete the file.
thanks in advance
Jafar K
|
|
|
|
|
Hi, I've recently started using Windows forms and need to create many threads which loop through a given CSV and process the contents to a method. I'm not sure of the best way of doing this. I can create a few threads but each thread processes each line rather than 1 line being processed by one thread and the next line being processed by another thread. The first value is a unique identifier if that helps.
Hope I've explained it ok, can anybody please advise?
Thanks
|
|
|
|
|
I would expect that one thread should read the file and place each line in a Queue. Then several other threads can read from the Queue and proceed from there.
|
|
|
|
|
Hi,
you could open a streamreader on the file, then launch a few threads all executing the same code, containing this pseudo-code:
while(!allDone)
lock the streamreader (or some other object)
read one line from the streamreader, and set allDone true if no more data available
unlock again
process the line read, if any
}
allDone is a bool, starting false, shared by all threads.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Sunday, January 31, 2010 10:44 PM
|
|
|
|
|
I'm just not convinced that that will yield a significant performance boost. And I suspect that decoupling the reading and processing will yield a more-maintainable system.
|
|
|
|
|
Neither am I, however the OP stated "need to create many threads", so I must assume those threads will be busy outside the lock most of the time, in which case I don't need code to read the entire file and pump it through a queue.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Thanks, but I'm new to this.
How do I go about locking my streamreader so each thread does a different line, etc?
Thank you
|
|
|
|
|
Hi,
not tested, you should read up on all classes and methods used, then adapt whatever needs adapted, and add error handling:
StreamReader sr;
bool allDone;
void handleFileWithManyThreads(string filename, bool waitTillDone) {
allDone=false;
sr=File.Open(filename);
List<Thread> threads=new List<Thread>();
for(int i=0; i<Environment.NumberOfProcessors; i++) {
Thread thread=new Thread();
thread.Start(runner);
threads.Add(thread);
}
if (waitTillDone) {
foreach(Thread thread in threads) thread.Join();
sr.Close();
}
}
void runner() {
while(!allDone) {
string line=null;
lock(sr) {
line=sr.ReadLine();
if (line==null) allDone=true;
}
if (line!=null) {
}
}
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Load the file contents into a list, and run the threads in a thread pool. When you queue the threads into the thread pool, assign an index into the list to the thread. Then, when a thread runs, it can simply retrieve the specified index item and be done with it.
I think it might be even better to queue just a handful of threads, assign a block of items to it (specifying the first and last index to process). This would save the time/resources associated with overhead regarding thread contexts and switching.
The thread pool will report itself ide when processing is complete, so you don't have to track the status/progress unless you really want to.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
If you're new to this, I think that the outlow programmers ideea is the best.
To make things even easier(not faster) you could use ParallelLINQ or the parallel task(s) library to process the datas from the list. This way you don't have to worry about threads, locks and other quite painfull stuff.
It's available as an extension/add on to .NET 3.5 SP1 and out of the box for .NET 4.0(soon to come).
|
|
|
|
|
Thank you very much for the replies.
I created 10 threads and broke down my file into 10 files. Each thread would loop through then.
This is what I went with in the end:
private void btnRun_Click(object sender, EventArgs e)
{
for (int i = 0; i < threadCount; i++)
{
CreateThread(i);
}
}
private void CreateThread(int threadID)
{
Thread thread = new Thread(new ParameterizedThreadStart(RunProcess));
thread.Start(threadID);
lstThread.Add(thread);
}
private void RunProcess(object threadID)
{
int id = (int)threadID;
for (int i = id; i < threadCount; i += threadCount)
{
ProcessByThread(Convert.ToInt32(threadID));
}
lstThread[id].Abort();
}
private void ProcessByThread(int threadNumber)
{
GetDataFromCsv("Batch" + threadNumber + ".csv", threadNumber);
}
|
|
|
|
|
what is wpf and where should i start?
|
|
|
|
|
Here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
It's the Windows Presentation Foundation, and is the replacement for Windows Forms. It provides a much richer experience than Win Forms as it's not tied to GDI+, so it's possible to create animations, 3d work, etc... with a lot less work than you used to have to do.
If you want to look into this, there are several good books on WPF - the two standard ones are WPF Unleashed[^] by Adam Nathan and Pro WPF[^] by Matt Macdonald.
"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
|
|
|
|
|
hi everyone i have wrote two application by socket programing that connect to each other by ip the problem is that if listener program has an invalid ip(being in a local network) the other application can not access it i mean that i dont know how to connect to an application that is in a local network
please help me
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:49am.
|
|
|
|
|
hi thank u for your answer and i really appriciate that here is my codes:
|
|
|
|
|
i have a dll that contains WPF controls
i want to add them into a windows form project
how could i do that ?
i added the source to the solution
i didn't see the controls in the toolbox..what's next ?
|
|
|
|
|
That's because a WPF control can't be used in standard Windows form.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
In order to host WPF in Win Forms, you need to add an ElementHost to your form, e.g.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
host.Child = myWpfControl; Obviously, you'd have to have instantiated myWpfControl before you add it to the host, but this is the general flow.
"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
|
|
|
|
|
i want to learn network programming in c#
can any body send be absolute beginning to network programming link
|
|
|
|