Click here to Skip to main content
15,896,606 members
Home / Discussions / C#
   

C#

 
QuestionSystem.StackOverflowException was unhandled Pin
cuongmits21-Apr-08 2:11
cuongmits21-Apr-08 2:11 
GeneralRe: System.StackOverflowException was unhandled Pin
Vikram A Punathambekar21-Apr-08 3:00
Vikram A Punathambekar21-Apr-08 3:00 
GeneralRe: System.StackOverflowException was unhandled Pin
leppie21-Apr-08 4:08
leppie21-Apr-08 4:08 
QuestionRe: System.StackOverflowException was unhandled Pin
cuongmits21-Apr-08 7:36
cuongmits21-Apr-08 7:36 
GeneralRe: System.StackOverflowException was unhandled Pin
Yusuf21-Apr-08 8:21
Yusuf21-Apr-08 8:21 
QuestionRe: System.StackOverflowException was unhandled Pin
cuongmits21-Apr-08 20:27
cuongmits21-Apr-08 20:27 
GeneralRe: System.StackOverflowException was unhandled Pin
Yusuf22-Apr-08 1:35
Yusuf22-Apr-08 1:35 
GeneralMulti threading To my Search Program Pin
shinboxe21-Apr-08 1:39
shinboxe21-Apr-08 1:39 
Hello.. im alittle new when it comes to handling threads and all the crap.. and i would really appreciate if someone would be able to give me some guidance tips..
i have tried to build a small search program who runs up of my entire hard drives (for now it was limited to windows directory)and to give me the strings that matches to the search box..
well it works perfectly.. though it takes a while to search because i dont know how to use multi threading..
i have tried reading articles but i always get stuck at some point... for now ive managed to create one single thread and when im trying to send another one .. they dont synchronize it just multiply the result by 2...can please someone direct me to the answer and help me abit.. wide explanations will be awesome
here's the code
the main procedure:
<br />
namespace SearchFile<br />
{<br />
public struct directors<br />
{<br />
public DirectoryInfo Dir;<br />
public bool processed;<br />
}<br />
public partial class Form1 : Form<br />
{<br />
<br />
directors direct;<br />
public string location = "";<br />
public delegate void invokegetdirecotrs(directors dr);<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
public void getDirectors(directors dr)<br />
{<br />
<br />
if (this.InvokeRequired)<br />
{<br />
invokegetdirecotrs inv = new invokegetdirecotrs(this.getDirectors);<br />
this.Invoke(inv, new object[] { dr });<br />
}<br />
<br />
else if( dr.processed == false)<br />
{<br />
dr.processed = true;<br />
int i = 0;<br />
Array Sub_Dir;<br />
FileInfo[] fi = dr.Dir.GetFiles();<br />
string comparest;<br />
Sub_Dir = dr.Dir.GetDirectories();<br />
if (Sub_Dir.Length > 0)<br />
{<br />
for (i = 0; i < fi.Length; i++)<br />
{<br />
comparest = fi[i].Name.ToString();<br />
for (int j = 0; j < comparest.Length - location.Length + 1; j++)<br />
{<br />
if (location == comparest.Substring(j, location.Length))<br />
{<br />
j = comparest.Length;<br />
listView1.Items.Add(fi[i].FullName.ToString());<br />
}<br />
}<br />
<br />
}<br />
foreach (DirectoryInfo d in Sub_Dir)<br />
{<br />
DirectoryInfo di = new DirectoryInfo(d.FullName.ToString());<br />
direct.Dir = di;<br />
getDirectors(direct);<br />
}<br />
<br />
}<br />
else<br />
{<br />
fi = dr.Dir.GetFiles();<br />
for (i = 0; i < fi.Length; i++)<br />
{<br />
comparest = fi[i].Name.ToString();<br />
for (int j = 0; j < comparest.Length - location.Length + 1; j++)<br />
{<br />
if (location == comparest.Substring(j, location.Length))<br />
{<br />
listView1.Items.Add(fi[i].FullName.ToString());<br />
j = comparest.Length;<br />
}<br />
}<br />
<br />
}<br />
<br />
}<br />
}<br />
}<br />

and the button click
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
listView1.Items.Clear();<br />
location = textBox1.Text;<br />
if (location != "")<br />
{<br />
DirectoryInfo dir = new DirectoryInfo(@"c:\divx");<br />
directors dr;<br />
dr.Dir = dir;<br />
dr.processed = false;<br />
ThreadStart starter = delegate<br />
{<br />
getDirectors(dr);<br />
};<br />
new Thread(starter).Start();<br />
<br />
ThreadStart starter1 = delegate<br />
{<br />
getDirectors(dr);<br />
};<br />
new Thread(starter1).Start();<br />
/*<br />
ThreadStart starter2 = delegate<br />
{<br />
getDirectors(dr);<br />
};<br />
new Thread(starter2).Start();<br />
*/<br />
<br />
}<br />
}<br />


i appreciate your help!
the lost guy ;[
GeneralRe: Multi threading To my Search Program Pin
J4amieC21-Apr-08 2:15
J4amieC21-Apr-08 2:15 
GeneralRe: Multi threading To my Search Program Pin
shinboxe21-Apr-08 3:35
shinboxe21-Apr-08 3:35 
GeneralRe: Multi threading To my Search Program Pin
Simon P Stevens21-Apr-08 3:35
Simon P Stevens21-Apr-08 3:35 
GeneralRe: Multi threading To my Search Program Pin
shinboxe21-Apr-08 3:54
shinboxe21-Apr-08 3:54 
GeneralRe: Multi threading To my Search Program Pin
Simon P Stevens21-Apr-08 4:22
Simon P Stevens21-Apr-08 4:22 
GeneralRe: Multi threading To my Search Program Pin
shinboxe21-Apr-08 8:57
shinboxe21-Apr-08 8:57 
Questionhow to know that an internet connection is alive at some instant? Pin
ptr2void21-Apr-08 1:03
ptr2void21-Apr-08 1:03 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
phannon8621-Apr-08 1:16
professionalphannon8621-Apr-08 1:16 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
ptr2void21-Apr-08 1:25
ptr2void21-Apr-08 1:25 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
Pete O'Hanlon21-Apr-08 1:44
mvePete O'Hanlon21-Apr-08 1:44 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
ptr2void21-Apr-08 1:54
ptr2void21-Apr-08 1:54 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
Pete O'Hanlon21-Apr-08 2:00
mvePete O'Hanlon21-Apr-08 2:00 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
Mustafa Ismail Mustafa21-Apr-08 2:02
Mustafa Ismail Mustafa21-Apr-08 2:02 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
J4amieC21-Apr-08 3:15
J4amieC21-Apr-08 3:15 
GeneralRe: how to know that an internet connection is alive at some instant? Pin
Mustafa Ismail Mustafa21-Apr-08 8:13
Mustafa Ismail Mustafa21-Apr-08 8:13 
Generalmake richtextbox transparent Pin
kamalesh574321-Apr-08 0:11
kamalesh574321-Apr-08 0:11 
GeneralRe: make richtextbox transparent Pin
Blue_Boy21-Apr-08 0:36
Blue_Boy21-Apr-08 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.