|
nd am having a problem in my application that ive been able to replicate using the code below.
I want the function TestTimeout to run only at certain times so im using Thread.Sleep(Timeout.Infinite); to stop it.
I'm interrupting the thread using the button below it works once however has no effect afterwards ? What should happen is it should display the message then sleep again until interpreted
private static Thread TimeoutThread;
private void Form1Load(object sender, EventArgs e)
{
var Job = new ThreadStart(TestTimeout);
TimeoutThread = new Thread(Job) { IsBackground = true };
TimeoutThread.Start();
}
private static void TestTimeout()
{
MessageBox.Show("Run");
try
{
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException)
{
TestTimeout();
}
}
private void button1_Click(object sender, EventArgs e)
{
TimeoutThread.Interrupt();
}
Can anyone tell me how to resolve this issue
|
|
|
|
|
I think that recursive call to TestTimeout is causing some problems. Does something like this do what you want (I have added a spinwait to simulate some work being done).
private static Thread TimeoutThread;
private void Form1_Load(object sender, EventArgs e)
{
ThreadStart Job = new ThreadStart(TestTimeout);
TimeoutThread = new Thread(Job) { IsBackground = true };
TimeoutThread.Start();
}
private static void TestTimeout()
{
while (true)
{
MessageBox.Show("Starting Work");
try
{
Thread.SpinWait(100000000);
MessageBox.Show("Finished Work");
Thread.Sleep(Timeout.Infinite);
}
catch (ThreadInterruptedException)
{
}
}
}
private void button1_Click(object sender, EventArgs e)
{
TimeoutThread.Interrupt();
}
<pre>
|
|
|
|
|
check out once that may be your form_load event called many times..
|
|
|
|
|
Hi guys nice to see u again ^^
i would like to implement a SysMsgProc Hook to get information about Scroll bar, menu, dialog box, ...
i found some information in msdn http://msdn.microsoft.com/en-us/library/ms632589(VS.85).aspx[^]
i don't know how to do that and if i can use it with SetWindowsHookEx (in user32.dll ) or there is another dll xD may be v_v
thanks for help ^^
|
|
|
|
|
For test purposes, let us take a user with following properties:
samaccountname=testuser1,OU=ou1,OU=test unit,...
Please note that there are two entries for the attribute OU.
Now I try to find out if OU=ou1 is set for user testuser1.
In C# (.NET 3.5), I do:
DirectoryEntry ent = new DirectoryEntry("LDAP://our.domain");
DirectorySearcher searcher = new DirectorySearcher(ent);
searcher.Filter = "(&(samaccountname=testuser1)(OU=ou1))";
searcher.SearchScope = SearchScope.Subtree;
SearchResult result = searcher.FindOne();
... and result is null.
searcher.Filter = "(samaccountname=testuser1)";
or
searcher.Filter = "(OU=ou1)";
get a result.
How does the correct Filter look like for the scenario described above?
|
|
|
|
|
How about:
(&(samaccountname=testuser1)(| (OU=ou1)(OU=test)))
/ravi
|
|
|
|
|
I have come across problem for which I'm looking for permanent solution.
Some software I'm working needs to have a version checking mechanism for update checking and disabling the installed version if necessary. It was decided to that a server be provided from which a small encrypted xml file is downloaded and checked.
I thought, "not too complex with Webclient", simply download the file decrypt and check it and then delete it. If an Exception then status is Unverified. Works file on XP machines when the file is removed from the server the exception happens like expected.
On the Windows 7 machine however it continues to succeed and even when the network is disconnected. NO exception is raised. I even took out the try/catch to confirm that - NO crash.
If set
client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
just incase, because I wanted to ensure the file was downloaded every time.
It is still coming from somewhere. I'm confused!!!!!
If anyone has an idea about this I would be interested in knowing about it.
Happy programming!!
|
|
|
|
|
Where should the exception be thrown - in some places and under certain circumstances exceptions get swallowed! E.g. in a Form Load or Shown event when the application is executed from Visual Studio; or possibly also on Win7 64 bit machines with those events.
|
|
|
|
|
From what I have tracked down, the exception doesn't occur because the 'old' file is actually being served up. It seems that the BranchCache service is being over kind to us and even ignoring the noCacheNoStore request. I shall confirm or otherwise on Tuesday when I'm back at work.
Happy programming!!
|
|
|
|
|
I think your only recourse is to run it under the debugger and investigate every variable and condition (in the appropriate block of code) until you find the problem.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Did you mean to specify BypassCache instead of NoCacheNoStore ? That's what I use to achieve a similar result and it works fine.
/ravi
|
|
|
|
|
Can you help me about problem delete multiline on listview
Thank you!
modified on Friday, April 8, 2011 6:36 AM
|
|
|
|
|
Possibly. It depends what the problem is.
|
|
|
|
|
Oh dear God! Do questions like this still exist!
|
|
|
|
|
They do indeed. How are you doing mate?
|
|
|
|
|
|
I'm not bad. I'm doing a fair bit of travelling up to Glasgow now, so may be able to make a DDD talk or two in Scotland.
|
|
|
|
|
I'm not allowed to discuss VB.Net in this forum.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Loop through the selected items and remove them.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If this was posted in the correct forum, yes, we could.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Yes.
It is quite simple really.
What you need to do is explain what the problem is and provide some code.
Then explain what you have attempted and where you think the problem is.
I think this is better than the altenative method, teaching everybody else to read your mind!
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
|
fififlowertot wrote: Hi , I needed to verify that the last 4 digits in a number are 0000. The
number was of format 999999-0000 so i checked with a regular expression
@"\d-\(0){4}" but now the '-' will not be there and it always just a number
with last 4 digits as 0 i.e 0000 I am unable to think of a regular expression
to validate this string. any help will be greatly appreciated.
This should have been asked in the Regular Expression forum. However, seeing that the question is here now, and seeing that I'm in a good mood, the regex for this is:
^(\d*(0){4}) [Edited to add deleted question in]
I'm not a stalker, I just know things. Oh by the way, you're out of milk. Forgive your enemies - it messes with their heads
My blog | My articles | MoXAML PowerToys | Onyx
modified on Thursday, April 7, 2011 12:33 PM
|
|
|
|
|
yeah i was just deleting this when the mail of a reply came in inbox. thanx.
|
|
|
|
|