Are you trying to make sure that after something happens in your worker thread that a method is executed within the context of the main thread, or are you just trying to signal the main thread from your worker thread.
Probably the easiest way would be to pass a waithandle to your worker thread and get your main thread to wait on the handle (or check it regularly) for the handle to be signaled and then go from there. But if thats the case then you might as well recode the worker thread as an asynchronous method call.
The above may not be to your liking Looking at the Mono project, the way they have implemented System.Windows.Forms.Control.Invoke() is place the delegate passed ot Invoke() in a queue. This queue is then checked in the windows message loop (which executes in the same thread as the control was created in), and any delegates in the queue are then called.
So you could create a synchronized queue, get your worker thread to place a delegate in this queue, and then either get your main thread to periodically check this queue or signal a waithandle, and then get the main thread to execute the delegates in the queue.
I was looking to actually call a method on the main thread in the same way as Control.Invoke() 'marshals' the call to the main thread in a windows form.
Your suggestions of passing a waithandle to the worker thread or using an asynchronous method call sound good and I will certainly look into them ( especially the async call, that hadn't occured to me at all )
Your description of how Mono works is very interesting and I imagine that microsoft do it in a similar way or at least thats how it appears to work. But it does seem to be a bit tricky for my feable brain and right now I need a quick and dirty solution.
Thank you very much for help, it was very useful to me.
I am having the same problem.
I am calling the FileWatcher component in the .NET framework from a server (middleware) class. If I place this on a form, I'm set, I just hand the FileWatcher class a reference to my form. The file watcher class then calls the form's Invoke method.
However I don't have a form, so am forced to implement the ISynchronizeInvoke interface myself.
Your suggestion to go look at the mono project seems like a good start. Can you tell me where to find this project?
My solution so far is to implement ISnychronizeInvoke and to create an delegate instance that will be executed when the callback is executed.
1. I register a call back.
2. The call back is executed. The sender is the operating system.
3. I then execute a delegate that I instantiated on the "target" thread.
NC State Archives
Visual Studio .NET only creates Windows apps, but there is a cross-platform, open-source version of .NET called Mono. You can use SharpDevelop[^] which can create Mono apps. SharpDevelop currently does not have many of the features of VS .NET, but it is being steadily improved, and it is FREE. You cannot currently run SharpDevelop on any OS but Windows, but I believe next version (0.95) will allow you to do this. You cannot build windows forms apps that are cross-platform yet, because System.Windows.Forms cannot be ported to other platforms.
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
I am creating a "Visual Studio .NET" deployment project to install some component assemblies.
I would like that the setup program make the assemblies appear in the Visual Studio .NET "Customize Toolbox" dialog box.
In your deployment project for you "developer" version, create a new registry key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders. Use a unique string for the key name. The Default value should point to the directory where your assembly is located.
You'll need two copies of your assembly, one in the GAC, and one in a normal directory.
I've been using Visual Studio 7.0 to develop a C# application for a while. Today, I downloaded and installed the .NET 1.1 framework and SDK. But I can't figure out how to get Visual Studio to start using the new version of the SDK. If I rebuild my project and run, it's still using .NET 1.0... you can see this in the output:
Actually, Visual Studio 2002 only targets NET 1.0.You you can not use the .NET 1.1 from within Visual Studio 2002. (
To build a .NET 1.1 App you have two options:
1. Use Visual Studio to write and organize your files and then use the command line compiler on the 1.1 SDK folder to build your app (but remember that NET 1.1 introduces some code-breaking changes to NET 1.0)
I have question. We are planning to write major stand alone app in .NET which hosts various GUI (Windows)
Screens( in ActiveX Objects) . Does .NET Remoting help us to host GUI Objects display remotely ?
Does .NET Support to display GUI Obejcts? or its just messaging protocol?
I have finally discovered that the Deployment project in Visual Studio .NET offers a GAC folder. I have just, when creating my deployment project, to place my assemblies in this folder.
And now, I have another question: I would like that the setup program make the assemblies appear in the Visual Studio .NET "Customize Toolbox" dialog box. How to do that?
I know you can make web-references dynamic, which then only need a small change in the web.config file to repoint them to the new location you want to look at.
My question is, can you do something aking to this with regular (non-web) references? Perhaps using the web/<application>.config file, or a manifest file or something?
We are looking to create a central library directory where we can keep our common libraries for access from any machine which needs them. One consideration was 2K's Distributed File System, but that is an awful lot of complications, especially since it means getting our domain administrators involved. So i was thinking there might be an easier way by being able to just put in a line which tells the app where to look for the reference at run-time. yes??
It would probably be eaiser to just setup a network share for the library, and add a project reference. I think deciding which asseblies to use at runtime is most suited to situations where you know the interface but you want the freedom to decide which assembly you will use to implement that interface.
I would just point out that assemblies run from a network share will have reduced permissions when using the default security settings for .NET. Depending on what your assemblies do, you may need to alter these settings to give your assemblies the necessary permissions.
OK, either my original post was too long for anyone to read or I'm the only person having this problem. Let me simplify things. Has anyone noticed flaky behavior from .NET when creating or using a custom IComparer? I'll probably submit this to Microsoft support, but that will take forever... In the meantime, has anyone run across this sort of problem?
Most sort algorithms need stable comparison functions. Your function seems to be returning random results when the objects are different, so the .NET framework gets lost.
Suppose you have created a function where A > B > C > D. Your IComparable should be stable and NEVER return B > A > D > C.
Comparison is, too, a transitive function. So, if A > B and B > C, you can safelly assume that A > C. Your function does not guarantees that.
I've dome some research for an Open Source DataGrid component for .NET but I couldn't find anything worth working with. What do you think of starting up a new project for a suite of Data-aware components that could be comparable to commercial ones?
Is there anybody interested on talking about that?
Last Visit: 31-Dec-99 19:00 Last Update: 10-Dec-23 20:26