|
Hi,
What do I need to do to end the thread after the Join?
The 3rd thread has a while loop and in side that while loop i got a nested for statement.
One for statement in another one.
I check for the volatile variable in my while loop. And once more inside the deepest for statement.
That should be enough right?
|
|
|
|
|
If you check the variable, it should end.
Are you sure there is nothing more happening?
Can't you put a break point in the last join and, instead of executing it, as all threads are stopped, check what's happening in the other thread? Maybe put some breakpoints at that moment and then allow the Join to go... you must see exactly what the other thread is doing.
|
|
|
|
|
Yes I'm sure. The variable gets checked alright. But it doesn't seem to stop it.
Here is that thread i'm talking about with the code:
private void FileComparerThread()
{
while (this.stopRequested != true)
{
for (int i = 0; i < Directory.GetFiles(this.dest).Length; i++)
{
string[] filePaths = Directory.GetFiles(this.dest, "*.txt");
for (int j = 0; j < filePaths.Length; j++)
{
if (this.stopRequested != true)
{
if (filePaths[i].ToString() != filePaths[j].ToString())
{
bool comparedFiles = this.FileCompare(filePaths[i].ToString(), filePaths[j].ToString());
if (comparedFiles)
Directory.Move(filePaths[j], Path.Combine(this.dest2, Path.GetFileName(filePaths[j])));
}
}
}
if(filePaths.Length > 3)
File.Move(filePaths[i], Path.Combine(this.dest, Path.GetFileName(filePaths[i])));
Thread.Sleep(5000);
}
}
}
And then I got a this.FileCompare() function that checks 2 files for equality thats it.
I've done some big time debugging. Its just looping those for statements.
Even though the stopRequested = true.
It's not comming out that for statement.
|
|
|
|
|
I think I know what's the problem.
You didn't return in the internal if.
So, stopRequested is true. Your method does not compare the files, but continue in it's loop, waits for 5 seconds and so on.
So, I think instead of:
if (this.stopRequested != true)
{
... some code...
}
You should use:
if (stopRequested)
return;
|
|
|
|
|
Hi,
You're right, About an hour ago i got an else statement after that if-statement with a return.
I'll use your suggestion. Saves me some line of codes :P
Thanks!
|
|
|
|
|
Yustme wrote: the last one doesn't seem to abort
Aborting a thread is a bad idea as it leaves things in an unknown state. But then maybe you're not really calling Thread.Abort() at all?
Yustme wrote: this.stopRequested = true;
This doesn't do anything, unless your thread is periodically checking that variable. But then you did not show such code, making me doubt you understand how your code is working.
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. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi,
I didn't abort the thread. That was just 'speaking'.
I know, i check its state on different places periodically.
The code has grown too big to post it. I've reduced it now.
I didn't see your post yesterday!
|
|
|
|
|
Please i would appreciate any help i can get on getting my project started,cannot integrate the different classes on my server.
|
|
|
|
|
You might need to read through some chapters on .Net remoting in a C# book. They will provide some samples that will start you up.Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I would like to be able to click a button (which is always located in the same area) of a external/downloaded html page?
Any help would be appreciated.
Language C# visual Studio.
|
|
|
|
|
Of specific HTML or all possible pages, including www.codeproject.com, wwww.google.com and others?
Or are you refering to Button submit within Form html tag?
|
|
|
|
|
Of all or any page.
For example... I download or view a page (lets say http://www.codeproject.com/Forums/1649/Csharp.aspx) and via code I click the "Search" button.
|
|
|
|
|
<form method="get" action="/info/search.aspx" name="Search" style="margin:0;">
<b>Search </b>
<input class="small-text" name="artkw" style="width:200px;" />
<select class="small-text offblack" style="font-weight:bold;" name="sbo">
<option value="kw">Articles / Quick Answers</option>
<option value="fm" selected="true">Messages</option>
<option value="s">Jobs</option>
<option value="ctlk">Product Catalog</option>
</select>
<input type="submit" class="button small-text" value=" Go! " />
</form>
As you can see, this is HTML for a submit. aka. Search. This has a GET method. it uses ? inside url. you can easly get what to send and then send it to url. in this case: /info/search.aspx
|
|
|
|
|
Unfortunately this is not what I'm looking for.
What I need is via c# I download a page onto my drive (let's. say http://www.writtenonthecity.com/display.php?image=2301&loc=8&type= ).
Now once the page is loaded I would do a search (in visual studio) in the page for the "Submit" button and via C# code i want to click it as if I was actually sitting there and using my mouse to click the button but via code.
I don't want to generate any buttons or edit box's or change the page's html, I just want to know how to click a button via code as if I was actually sitting there and clicking it with my mouse with a unknown downloaded page. Not a aspx page that I've created with a onclick event.
|
|
|
|
|
There is no simple code to just to call click event, because it doesn't exsist. When HTML parse, uses HTML information to handle that button. Here is examaple:
This is snipset of HTML
<form method="get" action="/info/search.aspx" name="Search" style="margin:0;">
<b>Search </b>
<input class="small-text" name="artkw" style="width:200px;" />
<select class="small-text offblack" style="font-weight:bold;" name="sbo">
<option value="kw">Articles / Quick Answers</option>
<option value="fm" selected="true">Messages</option>
<option value="s">Jobs</option>
<option value="ctlk">Product Catalog</option>
</select>
<input type="submit" class="button small-text" value=" Go! " />
</form>
Important lines:
1st. Line: Form tag has 2 atributes you need to take into an accound. that is Method and Action.
3rd. Line: Input tag is textbox, that has a name as 'artkw'
4th. Line: Is a combo box with a name 'sbo'. All items inside are used with option tag and inportant atribute is a value.
10th. It is an Input with atribute type="submit", witch is a button with a text " GO! " as specified in value atribute.
With this info you can easly request new page. You do not need to type any info or even show the form.
this is how it is processed
<form method="get" action="/info/search.aspx" name="Search" style="margin:0;">
<b>Search </b>
<input class="small-text" name="artkw" style="width:200px;" />
<select class="small-text offblack" style="font-weight:bold;" name="sbo">
<option value="kw">Articles / Quick Answers</option>
<option value="fm" selected="true">Messages</option>
<option value="s">Jobs</option>
<option value="ctlk">Product Catalog</option>
</select>
<input type="submit" class="button small-text" value=" Go! " />
</form>
The final url is "www.codeproject.com/info/search.aspx?artkw=text+to+search&?sbo=kw". And then it the server prepares next page based on variables sent.
ps: If you download page to your computer, next page is still depended on server, unless you are attempting to create a local server, where the requested page should be generated
|
|
|
|
|
Afternoon. Can anyone remind me of the custom attribute you can apply to a type which prevents Visual Studio from attempting to open the file in a designer rather than code view? I can *never* remember it, and Google's not helping. Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob,
I've hidden it in here[^].
I have a similar question: is there anything one can do to prevent custom controls that are part of the solution, to show up in the Toolbox?
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. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Thanks Luc. I have a feeling it was you who informed me of that attribute's presence in the first place!
You want to prevent things being automatically added to the toolbox? Most people like it the other way round. Only suggestion is try using Visual Studio 2003! Actually, I doubt it can be done.Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: You want to prevent...
Yes, I have a lot of Panel derivattives that I add programmatically, never through Designer, and they clog the Toolbox.
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. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
@Luc
I was facing a similar problem. Thus, I chose to disable loading of such controls in toolbar from AutoToolboxPopulate.
Then I added a toolbar button on menubar for "Refresh Project Toolbox Items".
Now, toolbar is not populated automatically. If I need any components in the toolbox, I simply select that project and click on the toolbar button. All compiled components are added to toolbar.
|
|
|
|
|
I so rarely want the Designer that I simply set the code editor as the default for forms and controls. I have to right-click to open the Designer.
|
|
|
|
|
I have a custom class TableProperties which has properties for CSS table styles. I have a CustomColor property that has a UITypeEditor to display the ColorDialog control and then convert the color value to a hex string (e.g., ffffff). When I iterate through the PropertyInfo collection the GetValue method returns the property type rather than the value.
foreach (PropertyInfo pi in tableProperties.GetType().GetProperties())
{
name = pi.Name;
ListViewItem lvi = listView1.Items.Add(name);
theType = pi.PropertyType.ToString();
lvi.SubItems.Add(theType);
value = pi.GetValue(tableProperties, null).ToString();
lvi.SubItems.Add(value);
}
The PropertyGrid works fine with the custom properties.
Thanks,
Mark
|
|
|
|
|
There are a few ways to fix this. The poblem lies here:
pi.GetValue(tableProperties, null).ToString();
The ToString() method, unless overloaded will return the type. If you can modify the TblPropTest.CustomColor code, you should overload this method. The code below adds an extension method to the Color class to output the Hex RGB value:
public static class ColorExtensions
{
static string GetHex(byte value)
{
return value.ToString("X");
}
public static string ToRGBHexString(this System.Drawing.Color color)
{
return GetHex(color.R) + GetHex(color.G) + GetHex(color.B);
}
}
This should be of help. If you cannot use this, please post the code for the TblPropTest.CustomColor type, as this is the root of the problem.Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
|
|
|
|
|
Yes I have overloaded the ToString method. Below are the methods in my CustomColor class. My ToString method was incorrect!
public new string ToString()
{
return string.Format("{0:X2}{1:X2}{2:X2}", _Red, _Green, _Blue);
}
public override string ToString()
{
return string.Format("{0:X2}{1:X2}{2:X2}", _Red, _Green, _Blue);
}
Thanks for the help!
Markmodified on Monday, March 1, 2010 11:53 AM
|
|
|
|
|
Hello together,
i actually have big problems to describe the project I want to realize.
First of all:
I do not ask for any finished solutions, but just for some advice.
We have a resource management tool for managing the ressources of our applications (a ton of win- and web-applications)
in a database.
It works very well for years now, but we often have the (I think common) problem, that our translators translate
the resources without the application context, which leads to the fact, that often a resource does not fit into
the button/label in the application.
Of course, we trim the resources to fit into the according control, but that is not a satisfying solution.
You could also say, that our translators should open the applications and have a look, where each resource will be
displayed, but due to the fact, that we have many applications, none of them is really doing it
(because they would have to install every application).
That is why I thought about a form, where they could enter the translations "into" the form of the application.
Each developer could prepare "his" form and would provide a library, that would be included into the resource
management tool.
There, the translators have the ability to open the form, and enter the translation "right into the controls".
Once again, this is no request like 'please code that for me', I am looking just for suggestions (maybe a tool like this
exists? I did not found sth. on codeproject. Or maybe there is some code, to load forms from other dll's).
kind regards
|
|
|
|