|
I made an application with a form that starts another thread.
see: http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2979123
Now when I drag or resize the form the thread blocks
for about 1/4 of a second...
Googled a bit and it seems to be a typical Windows problem,
is there a way around it?
I tought of even using a different proces (with "real time priority")
instead of that 2nd thread, but that's maybe a drastic and complex solution.
|
|
|
|
|
invader82 wrote: Googled a bit and it seems to be a typical Windows problem,
is there a way around it?
No. Considering Windows is not a real-time O/S (despite the priority name), your thread, even under the best of conditions, can be put on hold for a while other things are going on in the system. Your thread is never guaranteed a set amount of time to run, nor is it ever on a set schedule.
|
|
|
|
|
Well, the dragging takes place in the gui thread.
So I made a faster multimedia timer that periodically (about 1ms) invokes a method on the gui thread that:
- Sets the ManualResetEvent
- Does Thread.Sleep(0) to give up his quantum
It will never be 100% reliable, but still, it's way better than before
I know that windows is no real time operating system,
but using some real time middleware is not always an option.
|
|
|
|
|
Hi,
One simple thing you can do to reduce the amount of redrawing when dragging and resizing is to change the performance options for your PC.
In XP, go to the System control panel , click the advanced tab and then the performance button. Under Visual Effects there are a few presets but firstly try the best performance option and see if there is any improvement.
Alan.
|
|
|
|
|
I don't think that is a very good solution...
I found my own solution (not 100% reliable ...)
|
|
|
|
|
How exactly do I set s user to be disabled? I can get the value.. but how do I set it:
bool? AuthenticablePrincipal.Enabled
Gets or set a Nullable boolean vlaue that speecifies whether this account can authenticate...
but how do I set it to false?
UserPrincipal getUser = UserPrincipal.FindByIdentity(context, userName);
getUser.Enabled = false;
Does not work.
|
|
|
|
|
You also need to follow those statements with:
getUser.Save();
If you're already doing that, then I don't know. It's worked for me in the past.
BDF
People don't mind being mean; but they never want to be ridiculous.
-- Moliere
|
|
|
|
|
Well our AD is at server 2008 level.. That wouldn't make a difference would it?
I did try with a save before and it didn't work
|
|
|
|
|
I don't know if 2008 would make a difference or not, sorry.
Jacob Dixon wrote: a save before
No, you have to do the save after.
This is an existing user that's been saved to the store, I'm assuming.
BDF
People don't mind being mean; but they never want to be ridiculous.
-- Moliere
|
|
|
|
|
I have a program that contains a “start time” and “end time” to equal TempHours
I would like dHours to be the rounded figure.
I am trying to round the number up to next tenth of an hour
(IE 4.11 hours is 4.2 hours but 4.10 hours stays at 4.1 hours)
What do I need to add to the below statement to get it working
decimal dHours = Math.Round(decimal.Parse(TempHours.ToString()),3);
Thanks
|
|
|
|
|
ok,
Two questions for you
1) What does not working mean?
2) What type is the TempHours variable?
Alan.
|
|
|
|
|
Why are you changing it to a string?
If TempHours is already a numeric type (single, double, decimal, etc), just do this:
decimal dHours = Math.Round(TempHours, 1, MidpointRounding.AwayFromZero);
Second parameter is the number of decimals. 1 = To the nearest tenth. Third parameter tells it you always want to round up to the next value, never down.
|
|
|
|
|
Hi,
why would you call ToString() and then Parse() to turn a number into another number? This is nonsense, as it wastes lots of CPU cycles: numbers are stored in binary for a reason, it takes a lot of divide-by-10s to perform a ToString() on a number.
Math.Round does rounding in the regular way, i.e. 1-4 go down, 5-9 go up.
However you want 1-9 to go up, hence add 0.04 to the original number, then use Math.Round
Warning: you did not define how it should work for negative numbers; whatever straight code you come up with, there is a 50% chance it won't do what you want for negative numbers. If so, test for negative, and provide two different formulas.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thank you all for your replies. Great info! Although I didn't write the orig code, I'm learning quite a bit in trying to get it to work.
|
|
|
|
|
protected void Page_Init(object sender, EventArgs e)
{
RadioButtonList rbl = new RadioButtonList();
rbl.ID = "rbl1";
rbl.Items.Add("a");
rbl.Items.Add("b");
PlaceHolder1.Controls.Add(rbl);
rbl.SelectedIndexChanged += new EventHandler(rbl_SelectedIndexChanged);
Button btn = new Button();
btn.ID = "btn1";
btn.Text = "Button";
PlaceHolder2.Controls.Add(btn);
btn.Click += new EventHandler(btn_Click);
}
protected void Page_Load(object sender, EventArgs e)
{
}
private void btn_Click(object s, EventArgs e)
{
Label2.Text = "buttons click event fired";
}
private void rbl_SelectedIndexChanged(object s, EventArgs e)
{
Label1.Text="radiobuttonlist control selectedindexchanged event fired";
//RadioButtonList rbl2=(RadioButtonList)s;
//Label1.Text = rbl2.SelectedValue;
}
Jyoti Goel
|
|
|
|
|
there is no working SelectedIndexChanged in RB, use CheckedChanged instead
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
Have some patience, it is considered bad form to repost.[^]
hmmm pie
|
|
|
|
|
Another deleted post???
...No, just someone else posting the contents of thier brain
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Had posted the post in ASP.NET, but didn't know where my post will receive more traffic, since there were C# issues involved. So I double posted! Anyway I've resolved the issue. The original post is in the ASP.NET corner.
Thanks
|
|
|
|
|
The point is that you post it where it's most applicable, NOT where you think it will get the most attention.
"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." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi guys
I’m at my wits end with TreeNodes.
What i'm trying to do, to me is very simple. But for some reason I just can't get my head around it!
I’m currently working on a project where basically I’m splitting a Url address into a string array and creating each node and child node from the url segments (just like the Windows Explorer.)
\\ this is the plan
1) step through each url
string url1 = @"www.somedomain.com\home\about_us.aspx";
string url2 = @"www.somedomain.com\home\contact_us.aspx";
string url3 = @"www.somedomain.com\home\main.aspx";
2) split the current url into sections
3) process the url sections and create new nodes and child nodes or merge nodes if needed
4) output results
the final output I'm trying to get...
+ www.somedomain.com
_+ home
___+ about_us.aspx
___+ contact_us.aspx
___+ main.aspx
but in short i'm getting something like...
+ www.somedomain.com
_+ home
___+ about_us.aspx
___+ contact_us.aspx
___+ main.aspx
_+ home
___+ about_us.aspx
___+ contact_us.aspx
___+ main.aspx
Looking at the code below, Is there another way around this problem or am I just being stupid???
Any help would be very much appreciated. Please feel free to rip the hell out of my coding as I've kind of lost the plot!
Thanks again!
<pre>private void Form1_Load(object sender, EventArgs e)
{
TreeNode treeNode = new TreeNode();
treeView1.Nodes.Add(treeNode);
treeView1.PathSeparator = "\\"
// Add first url address
BuildNodes(treeNode,@"1\2\3\4\5\6\7");
// Add the next url address merging duplicate folders together...
BuildNodes(treeNode, @"1\2\4\5\6");
}</pre>
<pre>private void BuildNodes(TreeNode treeNode, string address)
{
string[] add = SplitNodes(address);
int max = add.Length;
string key = String.Empty;
TreeNode[] treeNodes = new TreeNode[max];
key = add[0];
treeNodes[0] = treeNode;
treeNodes[0].Text = add[0];
treeNodes[0].Name = key;
for (int i = 1; i < max; i++)
{
key = GetKey(key, add[i]);
treeNodes[i] = new TreeNode();
treeNodes[i].Text = add[i];
treeNodes[i].Name = key;
TreeNode[] tns = treeNodes[i - 1].Nodes.Find(treeNodes[i].Name, true);
// if node exists skip it else add the new node
if (tns.Length == 0)//if
{
treeNodes[i - 1].Nodes.Add(treeNodes[i]);
}
}
}</pre>
<pre>private string GetKey(string key, string value)
{
string delimiter = treeView1.PathSeparator;
if (key == String.Empty)
return value;
else
return String.Format(@"{0}{1}{2}", key, delimiter, value);
}</pre>
<pre>private string[] SplitNodes(string nodeString)
{
char[] delimiter = treeView1.PathSeparator.ToCharArray();
return nodeString.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
}
</pre>
<div class="ForumMod">modified on Friday, March 27, 2009 12:01 PM</div>
|
|
|
|
|
heres an idea... should do the job anyway...
void CreateNodes(string[] urls)
{
foreach(string url in urls)
{
string[] splits = url.Split('\\');
TreeNode temp = GetNode(splits[0], TreeView.Nodes);
if(temp == null)
temp = TreeView.Nodes.Add(splits[0]);
for(int i = 1; i < splits.Length; i++)
{
temp = GetNode(splits[i], temp.Nodes);
if(temp == null)
temp = temp.Nodes.Add(splits[i]);
}
}
}
TreeNode GetNode(string text, TreeNodeCollections nodes)
{
foreach(TreeNode n in nodes)
if(n.Text == text)
return n;
return null;
}
Life goes very fast. Tomorrow, today is already yesterday.
modified on Friday, March 27, 2009 12:47 PM
|
|
|
|
|
Thank you so much musefan, I'll give it a go!
|
|
|
|
|
Looked very promising, but the code you sent was creating each url folder as a root node.
It wasn’t breaking them down into child or grandchild nodes.
ps i'm using c#.net framework 3.5
here's the code you sent... I had to modify it slightly.
private void Form1_Load(object sender, EventArgs e)
{
TreeNode tn = new TreeNode();
treeView1.Nodes.Add(tn);
string[] urls = new string[2];
urls[0] = "a\\b\\c\\d";
urls[1] = "a\\b\\e\\f";
CreateNodes(urls);
}
void CreateNodes(string[] urls)
{
foreach (string url in urls)
{
string[] splits = url.Split('\\');
TreeNode temp = GetNode(splits[0], treeView1.Nodes);
if (temp == null)
temp = treeView1.Nodes.Add(splits[0]);
for (int i = 1; i < splits.Length; i++)
{
TreeNode temp2 = GetNode(splits[i], temp.Nodes);
if (temp2 == null)
temp2 = treeView1.Nodes.Add(splits[i]);
}
}
}
TreeNode GetNode(string text, TreeNodeCollection nodes)
{
TreeNode result = null;
foreach (TreeNode n in nodes)
if (n.Text == text)
{
result = n;
break;
}
return result;
}
|
|
|
|