|
|
Hello,
in class constructor, I have
public class oneclass : System.Windows.Forms.Form
{
...
public Thread th;
...
}
on events :
public void startsomethig()
{
...
try
{
...
}
catch(Exception ef)
{
MessageBox.Show("ef content: " + ef.Message);
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
th = new Thread(new ThreadStart(startsomething));
th.Start();
}
private void Button2_Click(object sender, System.EventArgs e)
{
th.Abort();
}
How do I do if I push on button2 to stop the thread
the catch above don't must intercepte stop error thread aborted. ?
Thanks in advance.
Frédéric
|
|
|
|
|
Hope I got it right that you don't want to show a message box if the ThreadAbortException is catched in the startsomething method.
To achieve this, add an extra catch block for the ThreadAbortException:
public void startsomething()
{
try
{
...
}
catch (ThreadAbortException)
{
}
catch(Exception ef)
{
MessageBox.Show("ef content: " + ef.Message);
}
}
www.troschuetz.de
|
|
|
|
|
You have to use Thread.ResetAbort() in the catch statement, otherwise the ThreadAbortException is rethrown automatically by the CLR. This is how .NET works.
|
|
|
|
|
I have a registry called HKLM\SOFTWARE\MyReg, I do do not know the name of the subkeys or how many but every subkey contaians a string "value" that I want to read.
Here is a the code that runs when a nutton is clicked
-MessageBox (mess1) displays the correct path of new subkeys
-MessageBox(mess2) does not display anything.
Any help will be greatly appreciated
************************************************************************
string[] daemonKey = new string[12];
string Elem, newDKey, numElements;
int count;
newDKey="SOFTWARE\\MyReg\\";
RegistryKey OurKey = Registry.LocalMachine;
OurKey = OurKey.OpenSubKey("SOFTWARE\\MyReg",true);
//find all the subkeys
daemonKey = OurKey.GetSubKeyNames();
//how many found?
numElements = daemonKey.Length.ToString();
//convert string to int
count=Convert.ToInt32(numElements);
for(int i=0;i<=count-1; ++i)
{
//new path for the key to open
newDKey=newDKey+daemonKey[i];
//open the new registry
OurKey.OpenSubKey(newDKey,true);
MessageBox.Show(newDKey,"mess1",MessageBoxButtons.OK,MessageBoxIcon.Information); \\\\shows correct path
//read the value for the string called value
Elem=(string)OurKey.GetValue("value");
MessageBox.Show(Elem,"mess2",MessageBoxButtons.OK,MessageBoxIcon.Information); \\does not read the value,blank-nothing
//reset the key
newDKey="SOFTWARE\\SOFTWARE\\MyReg";
**************************************************************************************
|
|
|
|
|
|
Hi:
I have a strange problem where the controls location on the form is changing without me touching it's position. Like the designer is somehow doing it by it self. I am changing some code segment (not related to the location of the controls) and when I return to the designer - the controls are redrawn in a different location (mostly they are shifted down).
* I am using the "RightToLeft=True" property
|
|
|
|
|
|
how do I use c# to change user security permissions (policies)?
I know to use System.Security, but not really sure what to do after that. I searched the msdn articles, but I guess I'm not sure where to really look as most of the stuff there is about internet security, or application permissions.
thanks,
Stephen
|
|
|
|
|
What o you mean by "user security permissions"? This can mean a bunch of things, including the permissions set you use in your application. Or are you talking about changing the users Domain and Local account rights, like group membership?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
local account rights (like the things you can change with the app "gpedit.msc",(try running it with the windows command prompt, if you are running windows xp))
|
|
|
|
|
Just about everything you see in the Group Policly Editor are registry hacks. Nothing special there. The trick is knowing what to do with what registry keys and values. That information you can get from the template files that GPEdit uses. Just search for the filenames. Be warned though, some of those template are HUGE.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a frustrating problem which I have struggled with for a few months and it is driving me mad. I expect it is something silly I'm doing wrong but I have not been able to find any advice on it so far.
Using C#.net
I create a new sqlDataAdapter by dragging it from the toolbox onto my form. I configure it to get data from my database.
I them Generate a dataset. If I choose to add the new table to an existing dataset, which is what I want to do most of the time, I get the problem.
The problem is that when I go to use the table it doesn't appear to be in the dataSet and so i can't for example bind to it.
I have struggled to get by, by deleting the dataset and re creating it with the same name which works fine but I then have to fix the auto generated code by re applying binding rules etc which waste time and effort.
If any of you experts can spare a few minutes to help me understand what I'm doing wrong I would be a happy newbie again.
EBKid
|
|
|
|
|
Does anyone know what the command line argument to launch a screensaver's options/configuration dialog is on Windows XP Pro?
From most of the example source code I can find on the web, it would seem to be '/c' but that does not seem to work for the screensaver I have written. I've tested my code and if '/c' is the first argument then the options dialog is launched but Windows XP does not seem to be supplying the '/c' argument when I right click on my .scr file and select the 'Configure' option from the menu.
After sticking an throw Exception call right at the start of my screensaver's main function, then running the 'Configure' option from the right click menu for the .scr file, then attaching my debugger to the screensaver when it throws the exception, it would appear NO arguments are being passed to the screensaver (args.length=0). I take
it this means that windows must try and launch the configuration dialog some other way? If so does anyone know what the other way is?
I'm the screensaver is written in C# and I am running Visual Studio .Net 2003 and Windows XP Pro. Does anyone know of any windows settings that could maybe be causing this?
Cheers,
CoffeeZombie
|
|
|
|
|
After more web searching, I'm starting to suspect it might be a local windows setting causing the problem. I've also tried running the screensavers supplied with Windows XP (in ..\windows\system32\) with the /c command line option, this does open their configuration dialogs.
So I'm wondering what my app is missing to not pick up the option, although most of the C# demo screensavers I've tried still seem to get it wrong too...
|
|
|
|
|
I mean I have a class in C++ in a DLL with exported functions and of course constructor and destructor.
Can I link to this class from C# somehow? I just found a way to link global C functions.
What about C++ classes and methods?
|
|
|
|
|
Yes, search codeproject, msdn, or google for P/Invoke, aka platform invocation services. It allows managed code to call into unmanaged exported functions. While this was created primarily for calling into the Win32 API, it can be used on any C/C++ dll. Also have a look at P/Invoke.net.
Any remotely useful information on my blog will be removed immediately. There are 10 kinds of people in the world. Those who have heard of the ubiquitous, overused, worn-out-like-an-old-shoe binary "joke" and those who haven't.
Judah Himango
|
|
|
|
|
Yeah. I found that before. But my question is how to call exported classes? Of methods of classes - not just global exported C/C++ functions.
|
|
|
|
|
Hi gurus,
I have two questions for you guys,
I would like to know how I can convert the contents of a string to a byte[] array?
Also, what is the equivalent of the >>> java operator in C#?
Thanks
Best regards.
There is no spoon.
|
|
|
|
|
|
I'm writting some remote admin software in C#, I would like to be able to implement a remote desktop, much like what MS does with the windows terminal services, however, i'm too poor to pay for this, and hence want to write my own. Unfortunately, I'm not too sure where to start.
I'm intend implementing the solution on Win2k/WinXp. I have VNC connections to the destination networks, however, an HTTP connection solution would be optimally desired.
I currently can see one option available to me and it's not the optimum way. To use a screen grabbing process and download compressed images and mouse coords of the remote machines desktop to the server software, while coordinating keyboard/mouse input between the server & client software.
Using this method, a screen grab of 256 colours, 1024x768 resolution, zip compressed, the file size of the image is about 40-90 KB. With the bandwidth available to me, which is about a 500 Kb/s (62 KB/s) cable connection, the results are going to be slow frame rate of about 1-2 frame/s, which is not really acceptable.
If anyone can give me any pointers to source code or methods to implement a better way, it would be most helpful.
|
|
|
|
|
Take a look at the RealVNC protocol specification, that should give you some ideas.
http://www.realvnc.com/docs/rfbproto.pdf
|
|
|
|
|
Thanks for that, i'll have a read
|
|
|
|
|
The Load event of a Form lets you write code before/after the form is loaded (don't know for sure). The doc says "Occurs before a form is displayed for the first time.".
Question: Is there a way to do something after a form is displayed for the first time?
I want to do some lengthy processing and it would be cool to have the form visible before displaying a wait-window or a wait cursor. I already tried to handle the WM_SHOWWINDOW message, but unsuccessfully.
Maybe I could post myself a message with PostMessage (if it is available)?
--
Affordable Windows-based CMS: www.zeta-producer.com
|
|
|
|
|