I'm new to C# multithreading and I read that to resolve deadlock it is best to use monitor with timeout.With this in mind I used the following code to see what happens to the deadlocking generated.
The result is the following exception
Unhandled Exception: System.Threading.SynchronizationLockException: Object synchronization method was called from an unsynchronized block of code.
Why this? What's wrong with my code or my approach?
which implies that Monitor.Exit can be called on a thread , for a resource only if that thread has already acquired lock for that resource.
you are calling Monitor.Exit (one out of try statements) on threads without assuring that a thread has already successfully acquired monitor on a specified resource. (i.e Monitor.TryEnter may not have been successfull). please Check the returned value from Monitor.TryEnter for both 'First' and 'Second' rountines.
Cheers to you. I'm now on the right track. Basically I load in the kernall32.dll and I can call the DeviceIoControl() method from there. P/Invoke is a way to make interop possible by loading .dlls from the past. Very nice. Thanks very much Ed.Poore
Why would you want to do that? Wouldn't it be better to set-up a streaming server or something like that, take a look at Windows Media Encoder[^]. Just set-up your server and connect to it from the client program.
I'm writing a program that needs to take a list of hostnames/usernames/passwords and change each machine's registry settings over the network. I've tried using OpenRemoteBaseKey, but that only allows for a hostname input. I have limited network programming experience and was wondering if there was an easy way I could connect to each of my nodes over the network to change the registries. I can elaborate if needed. Thanks in advance!
Sorry if it sounds like a stupid question. I did a bunch of searching before I asked here, but I'm kind of lost as to what's a good way to do this. Most links just explained how to access remote registries that you already have permission to access. If you could just point me in the right direction, I'd really appreciate it.
What about the RegistryKey.OpenRemoteBaseKey[^] method? Doesn't that do what you want, obviously you'll need to be logged in so presumably if you're a domain administrator then you can just run the code. If you have individual usernames/passwords for each computer then my guess is that you'll have to access the machine through explorer first to "log" onto it. Once that is done then you should be able to update it.
I have no idea what I just said. But my intentions were sincere.
OpenRemoteBaseKey only takes the hostname as an input. I need to use a username/password, also. I did some more searching and saw this - http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/37d17466c08886cb/935e84260c3a280f?lnk=st&q=c%23+remote+registry+username+password&rnum=9&hl=en#935e84260c3a280f
I'm assuming this is what I'm looking for hopefully.
For example I'm buiding Find/Search function in new form and I want to be able to search for sting in parent form from this child form (child form have text box where user enter word he is looking for)?
Parent form have multi Rich Text Box(es) (in tabs)... menus etc
So this is probably simple I tried few things but none works... I guess I'm just doing something wrong.
If you have a Form (say mainForm) containing text, and you want an interactive search facility, you could create a dialog using a new Form (say findDialog)
which has mainForm as parent (so it hides when mainForm hides), and which is
shown as modeless dialog (i.e. it can give up focus to other windows in same app).
Now mainForm can have button event handlers attached to the buttons of findDialog,
read an editTextBox on findDialog, and do whatever is required within mainForm.
So the trick is in mainForm attaching event handlers to another form's buttons,
but then it did create that other form (findDialog) so it has a reference to it.
Hence it boils down to one of the following:
- make the Controls on findDialog public (is not what Visual Studio Designer does
by default, but there is a "Modifiers" field on the properties panel)
- add public properties to get access to the non-public controls you need
- add one or more public methods to findDialog to attach an event handler to the
non-public controls you need.
The choice is yours.
Personaly I often create dialogs programmatically (rather than through Designer)
and make all controls public.
-- modified at 14:05 Saturday 6th January, 2007
Last Visit: 31-Dec-99 18:00 Last Update: 28-Sep-23 15:51