|
Darin Cruickshanks wrote: Any help greatfully recieved!!!!!
I don't know what you want us to do. All the things you mentioned are viable but none are as simple as write some code and it works. One needs an understanding of the logic and timing of IPC to work successfully with it. IMHO, and with my experience of doing IPC since 1995 in various methods and languages, .NET Remoting is very simple, but again that's from my perspective not yours.
led mike
|
|
|
|
|
Use sockets. Don't broadcast without a connection, it's wasteful.
You'll have to implement some logic and dig deeper into IPC to resolve your object lifetime problem and maybe write more robust shutdown code if you pursue that direction.
With a socket, you'll establish a connection to the service, and on a successful connect on both sides, make routines for server sending for each client and client receiving data. The shutdown code will be important in that case as well.
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|
|
I have an abstract class I am writing that i want to inherit from multiple other classes. i am running into an issue, however. i have the following :
protected abstract List<> GetList();
I am trying, if possible to make it that the classes that inherit this one can set the type for the list. so in class 1 it would be
public override List<string> GetList()
class 2
public override List<int> GetList()
clss 3
public override List<float> GetList()
Is this possible? what do i use in tthe inherited list<> object?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Make your class generic
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
beautiful. Just went to MSDN and gave myself a quick lesson in genericmethods, and now I'm cooking with gas. Thank you!
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
You are welcome
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I have another one for you if you are interested. Same abstract class, i have a Get() method. Similar problem, only rather than returning a List<> object, it is for individual objects, so class one would be public override int Get(), class 2 public override string Get(), etc.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
You can use T as a return type of the Get() method
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
|
Thanks man
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
I have moved on to another class inheriting this class, and have found a new problem.
here is my code:
public abstract List<T> GetList<T>() where T : Class1,new();
here is my issue. now i am trying to use the same abstract class to make another class, so this one would need to look like:
public abstract List<T> GetList<T>() where T : Class2,new();
however, i cant have them both in the same abstract class, and i cant seem to figure out how to do essentially this (i know this here doesnt work):
public abstract List&lt;T&gt; GetList&lt;T&gt;() where T : (CLass1,Class2),new();
Any ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
As you know C# does not support multiple inheritance of implementation so at most one base class can be used in a constraint.
Just read the documentation: An Introduction to C# Generics[^]
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hmmm.... I will need to figure out another way. maybe i should not be bothering to include it in the bastract class, for now. this is my project and i am the architect and sole programmer,so it should not be thta big a deal.
Thank you again for all of your help.
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
If you want your T parameter to inherit from Class1 and Class2 it means that either Class1 must inherit from Class2 or Class2 from Class1. In either cases you will need to specify just one class as a base class in constraint list as it will automatically mean that T inherits from the second class too.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi all,
Let's say I have a.exe and b.exe. Both are coded in C#.
a.exe have a textbox and a command button while b.exe have a label.
I run both exes. What I want to do is to type something in a.exe, "Hello Wolrd" perhaps, press the command button and have b.exe display the message on the label.
I don't want to use file streams and SQL for this.
Thanks!
|
|
|
|
|
Look up named pipes. I used them a while back for comunicating between a c++ app, and a c# app. It worked out pretty well.
There might be something a little simpler for just C# -> C# but i don't know about it.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
WCF is the way to do this nowadays. The old way I would use for simple stuff is the WM_COPYDATA message.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks!
|
|
|
|
|
I have a Setup Project in which some files are written in Cyrillic fonts (Bulgarian Phonetic). Visual Studio underlines these files and displays a warning Invalid language characters in property 'Name' . When install the files, the Cyrillic fonts appear as junk text - boxes. How can i fix this???
Still learning...
|
|
|
|
|
Hi. I'm making a MDI Windows Form Application that has some child forms.
It behaves like "MS power point slide show". So it shows its child forms in sequence. The child forms have several label controls - about 10 controls each.
My problem is that when each child form shows up, the child form's background image and the label controls are NOT come up concurrently. I've already checked to use double buffering on the child forms but the transition of the child forms is not clear and smooth.
Is there any solution? Like when the form is to be shown, pending any control's display and when the last control's data has written on memroy, then pops up with all the controls at once.
Please help me out!!
|
|
|
|
|
Hi all,
I am getting problem in uploading file with ASP.NET (C#). I have set almost all property of HttpWebRequest instance. I have too set properties in my Virtual directory.
I am getting error as "Cannot connect to the configuration database". I dont know what is configuration database in these case. My application takes 10 second when it execute the below code:
HttpWebResponse httpResponse =httpWebResponse)httpRequest.GetResponse();
I have used Stream to write uploaded file content. It seems to be working fine. Even I am getting my Stream object by GetRequestStream().
========================================================================
here is my code.
string URI = "http://" + txtServerIP.Text + "/" + "VDir" + "/" + fUpload.FileName;
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(new Uri(URI));
FileInfo fileInfo = new FileInfo(fUpload.PostedFile.FileName);
httpRequest.Method = WebRequestMethods.Http.Put;
httpRequest.AllowWriteStreamBuffering = true;
httpRequest.Credentials = new NetworkCredential(txtUserName.Text, txtPassword.Text);
httpRequest.ContentLength = fileInfo.Length;
httpRequest.ContentType ="text/html";
FileStream fs = new FileStream(fUpload.PostedFile.FileName,FileMode.Open);
Stream stream = httpRequest.GetRequestStream();
contentLength = fs.Read(buff, 0, buffLen);
while (contentLength != 0)
{
stream.Write(buff, 0, contentLength);
contentLength = fs.Read(buff, 0, buffLen);
}
stream.Close();
fs.Close();
//Here it takes 10 seconds.
HttpWebResponse response = (HttpWebResponse)httpRequest.GetResponse();
Could you pls help me.
Thanks,
Regards
Chintan
HCL Technologies...India
(Carefully) listen->(Deeply)Think->(Clearly)Understand->(Patiently) reply...
|
|
|
|
|
|
Hi there,
I am creating my first multi threading app. And I now I'm stuck on here.
Here's my Code:
<br />
public partial class FrmMain : Form<br />
{<br />
<br />
Thread threadVBNums, threadCNum;<br />
private void StartProcess()<br />
{<br />
this.threadVBNums = new Thread(new ThreadStart(this.AddVbNums));<br />
this.threadVBNums.Start();<br />
<br />
this.threadCNums = new Thread(new ThreadStart(this.AddCNums));<br />
this.threadCNums.Start();<br />
}<br />
private void AddVbNums()<br />
{<br />
for(int i = 0; i < 20, i++)<br />
{<br />
this.vbText.Text += ("Main thread: {0}\n", i);<br />
}<br />
}<br />
<br />
private void AddCNums()<br />
{<br />
for(int i = 0; i < 20, i++)<br />
{<br />
this.cText.Text += ("Main thread: {0}\n", i);<br />
}<br />
}<br />
<br />
}<br />
And this is written in Windows Application. So the other code is same as normal CS app. code.
Now this gives me an error saying
Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
I know that .NET do not allow me access controls on form. But I don't know how to solve this??!!
Can someone tell me what is happening wrong and how to solve it??
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
To avoid this problem, I would suggest you use a BackgroundWorker. This component will handle much of the threading for you and allow you a way modify controls on the form. It has a few very helpful methods...RunWorkerAsync() , ReportProgress(), and WorkDone().
You can call the ReportProgress method within your for loop like
<br />
private void StartProcess()<br />
{<br />
this.bgWorker.RunWorkerAsync();<br />
}<br />
<br />
private void bgWorker_DoWork()<br />
{<br />
AddCNums();<br />
}<br />
<br />
private void AddCNums()<br />
{<br />
for(int i = 0; i < 20, i++)<br />
{<br />
this.bgWorker.ReportProgress(0, i)}<br />
}<br />
<br />
}<br />
<br />
private void bgWorker_ReportProgress(object sender, ProgressChangedEventArgs e)<br />
{<br />
if(e.ProgressPercentage == 0)<br />
{<br />
int i = (int)e.UserState;<br />
this.cText.Text += ("Main thread: {0}\n", i);<br />
<br />
}<br />
}<br />
<br />
<br />
It's very clean.
Lester
http://www.lestersconyers.com
|
|
|
|
|
You'll have to add a Method to handle it that looks something like this...
private delegate void TextBoxUpdater(TextBox t, String s);
private void UpdateTextBox(TextBox t, String s){
if(t.InvokeRequired) {
t.Invoke(new TextBoxUpdater(UpdateTextBox), Object[]{t, s}));
} else {
t.Text = s;
}
}
Call this from your thread routine in place of manually setting the control text.
The above code may not work, I didn't compile it, but you get the idea. You have to check "InvokeRequired" on a control that you want to cross thread, and call the updating method on the UI thread using a delegate.
Scott
"Run for your life from any man who tells you that money is evil. That sentence is the leper's bell of an approaching looter." --Ayn Rand
|
|
|
|