|
Thank you very much !!!
Nho'c ti`
|
|
|
|
|
Does anybody know how I could get a current property value from a loaded process? What I am trying to do is to have a user log-in in a main application, which would initialize a user object containing all the neccessary information about a user, and then every other application openned afterword, while the main application is still open, would use the same user object that was initialized in the main application. This would save the user from having to log-in again, it would save having to make unneeded trips to a remote database, plus it would save having a database connection for every application that is openned. Any suggestions or comments would be greatly appreciated. Thanks
|
|
|
|
|
What happens if you put it into a class library module and then reference that module in your different programs / segements?
I have a program that maintains a form of program state in via an external (seperate project) class (with static members and properties). It is referenced and initialized in the main program which keeps a hold in it while all the other modules reference the DLL and have access to the data.
The only data I think you would have to worry about is process or thread specific data. Other than that it seems to work fine.
Rocky Moore <><
|
|
|
|
|
I have the user object in a class library and it is referenced by my other programs. I didn't think about making all the methods static but I think I would prefer to keep it as an instance class. I just need to know how to get an instance of that class from my main application when it is already an active process. Any other ideas?
Shaun
|
|
|
|
|
Shaun Becker wrote:
I just need to know how to get an instance of that class
That is the reason for the static. You can add a class with a static property that you assign the instance of the class you want to use. This is what I do with my Data Abstraction classes. I have a class that has memebers which are static but the values in this are static. The instance of the class you wish to use is available to all other modules.
Rocky Moore <><
|
|
|
|
|
I tried that and it didn't work for me, unless I did something wrong. I had a class library with two classes. The first class just held a static reference to an instance of the second class. Then I had two applications that referenced the class library. Each program checked the first class to see if the static reference was already set. If it wasn't set, it sets the reference to a new instance of the second class. If it was set, it displays the contents of the second class. The class was only static for each application process and not cross-process.
Hopefully I am explaining what I am trying to do correctly. I am writing a logistics application suite. It will have a main program, a maintenance program, an order entry program, and an admin program. The main program will just control security while all other application are running. Whenever any of the other programs start up, first it is going to check if there is already an instance of the application running using System.Diagnostics.Process.GetProcessesByName(). If there is then it will just activate that instance. If there isn't then it will then check if there is an instance of the main application using System.Diagnostics.Process.GetProcessesByName(). If there is an instance of the main application, then it will just get a reference to the user object from the main program. If there isn't an instance of the main application, then it will create a new process of the main application with System.Diagnostics.Process.Start(), which will require the user to log in and that will intialize the user object. Then the executing program will get a reference to the user object from the main program that was just started. I hope this explains everything I am trying to do. If you have any suggestions on how to do this or of a better way to reach the desired outcome, I would greatly appreciate it. Thanks
Shaun
|
|
|
|
|
Do you happen to have all the exe's and dll's in the same directory?
Rocky Moore <><
|
|
|
|
|
Yes, they are built to common bin directory.
Shaun
|
|
|
|
|
Is there a non-threaded class that's like System.Net.WebRequest? When I use WebRequest/WebResponse in a thread pool, I sometimes notice, under heavy load situations, that WebRequest/WebResponse seems to use a threadpool for its implementation.
Actually, I may be wrong, and that only WebClient happens to use the asynchronous version of WebRequest/WebResponse, which is annoying when my threadpool is full, and WebRequest/WebResponse can't run asynchronously, so WebClient bombs.
But if I have to use WebRequest/WebResponse, no biggie.
|
|
|
|
|
Argh. Reflector confirms what I suspected, that WebClient and WebRequest.GetResponse() both depend on WebRequest.BeginGetResponse(), which requires at least two free threads in the system threadpool.
That's pretty annoying. But not as annoying as how WebClient and WebRequest/WebResponse don't have a satisfactory overlap in power. WebClient makes certain common things easy, like POSTing data. WebRequest/WebResponse allow for certain things like changing the TransferEncoding or setting timeouts, but then I have to write my own UploadValues() for WebResponse, and all of the URL encoding functions are private. Useless!
|
|
|
|
|
hello,
i want to create a dialoge box and then dispose or close it, how can i do this in c#? can i?
ASIM
Asim
|
|
|
|
|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace SolidAvatar
{
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button cmdOK;
private System.Windows.Forms.Button cmdCancel;
private System.ComponentModel.Container components = null;
public static DialogResult DoShowDialog(IWin32Window owner)
{
Form2 myForm = new Form2 ();
return myForm.ShowDialog (owner);
}
private Form2()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
if(components != null)
components.Dispose();
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.cmdOK = new System.Windows.Forms.Button();
this.cmdCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
this.cmdOK.DialogResult =
System.Windows.Forms.DialogResult.OK;
this.cmdOK.Location = new System.Drawing.Point(112, 200);
this.cmdOK.Name = "cmdOK";
this.cmdOK.TabIndex = 0;
this.cmdOK.Text = "OK";
this.cmdCancel.DialogResult =
System.Windows.Forms.DialogResult.Cancel;
this.cmdCancel.Location = new System.Drawing.Point(208, 200);
this.cmdCancel.Name = "cmdCancel";
this.cmdCancel.TabIndex = 1;
this.cmdCancel.Text = "Cancel";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.cmdCancel, this.cmdOK});
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
}
}
}
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
If you just want to display a message, use
MessageBox.Show("message", "heading").
-or-
Create the form and call it using ShowDialog() instead of Show().
You can have the form return you Yes or No (or Cancel) by setting a value like
like
this.DialogResult = DialogResult.OK
And then the form that called it can retrieve it by:
if(myDialogBox.DialogResult == DialogResult.OK)
{
//code here to act on that.
}
hope that helps
|
|
|
|
|
In C++ the OnIdle() function is available from CView. How can I gain access to it in C# for a Windows based application. A simple application with one form.
thanks
|
|
|
|
|
Subscribe to the System.Windows.Forms.Application.Idle event.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
private void Form1_Load(object sender, System.EventArgs e)
{
Application.Idle+= new EventHandler(this.OnIdle);
}
private void OnIdle(object sender, System.EventArgs e)
{
// Spams you with message boxes.
System.Windows.Forms.MessageBox.Show(this, "Idling");
}
|
|
|
|
|
That:
McGahanFL wrote:
// Spams you with message boxes.
...would be my expectation. As I am not a MFC programmer, I do not know what the OnIdle() function does. I was guessing that the Idle event is the equivalent.
The help file for the Idle event states: Occurs when the application finishes processing and is about to enter the idle state. This seems to occur rather frequently.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
I would like to create a .NET application using C# language since C# seems good for rapid application development. I would also like to create the GUI using the C# application wizard. (not MFC, or WTL!!!)
How can I use DirectShow AND the Microsoft Speech .NET SDK within the same application? All the DirectShow SDK examples are written in C++. All the .NET speech examples are written in C#. I've read that some people use "wrapper classes" to use C# with C++.
Can I write the bulk of my application in C# and use C++ only for the DirectShow portion of it? Is approach possible as well?
Also, I'd like to "skin" my application, or in the very least give it some "personality" with rounded buttons and some custom controls that I create myself. Can I still use the Win32 API and the "layered" windows feature to skin a GUI created with C#? Is there any other way of creating that "custom" look?
I'm new to this stuff and I'm really confused. What's worse, is that I read all kinds of information about "managed code" and how "...DirectShow does not use managed code.....DirectShow is built upon COM objects.... .NET allows one to mix managed and unmanaged code in the same application..." blah blah blah....it can get very confusing.
All I want is some direction and advice on what to do 1st, 2nd, 3rd... I just don't know where to start... I don't want to read a 400 page book on ATL and COM if I'll be using C# which hides the COM internals... you know what I mean?
|
|
|
|
|
I show you two links in CodeProject about DirectShow in C#. Did you see them?
Mazy
No sig. available now.
|
|
|
|
|
I've seen all the links in CodeProject.... CodeGuru.... DeveloperFusion.... Develop... blah blah blah....there's so many.... enough to confuse me... trust me.... I'm new to this stuff... I need a little direction on what to read....
For example: Can I create a C# forms application, then "wrapper" all the C++ unmanaged Directshow stuff into C# managed code? And also incorporate the speech SDK into the same application.
If the answer is "yes", then how much work am I looking at?
Thanks.
Brian
|
|
|
|
|
Brian JR wrote:
Can I create a C# forms application, then "wrapper" all the C++ unmanaged Directshow stuff into C# managed code? And also incorporate the speech SDK into the same application
Yes you can. You have to write them in a dll and use them in your C# application. I think thats really hard work,but doable. Do you know how to use win32 API in C#? you can use your Dll,the same way as you use win32 API in C#,again there lots of articles about the topic like this one:
http://www.codeproject.com/csharp/c__and_api.asp[^]
Thasts all I can show you because I don't have experience of useing Directshow. Hope it helps.
Mazy
No sig. available now.
|
|
|
|
|
Oh God... you're scaring me...
|
|
|
|
|
OK. I found this type library for DirectShow: Seems like no one else has taken this approach. Do you know why?
http://www.kohsuke.org/dotnet/directshowTypelib/
Does this type library solve my problem of working with DirectShow in .NET? So I can use the type library to do MC++ and C# programming?
Brian
|
|
|
|
|
|
Ahhh... now I think it's starting to make sense! Thank you!
But how do I "derive" a C# class from a Managed C++ class?
"2. You can create GUI in C#, it's easy enough even for beginner. But if you want to create custom controls, I wouldn't advice.
The fastest way is to use controls created by someone or just "skin" your application as it's normally done with multimedia applications.
These "custom" controls - are you talking about ActiveX controls? Where do I get these custom controls? Can I put these custom controls into the C# form that I created?
Could you elaborate on the skinning process? What happens to the C# form I created when I perform the skinning process? Can the C# form and the skinning process co-exist? Also, when I trigger a menu item on my "skinned" application, and a submenu pops up, then how do I process to skin the submenu? That's what I'm confused about.
Any help would be greatly appreciated. Sounds like you are familiar with this process.
Brian
|
|
|
|