|
|
if i have a multi-threaded client server(lets consider 1 server and many clients).and i have to run a .exe file on my server. and i want each of the user threads which contains data to go to the .exe file which will run with these inputs and then reply the output back to the client through the server.
Is this possible??
I really Appreciate ur help
|
|
|
|
|
Sounds like you want a web service on the server, perhaps ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
As Christian said possibly a web service, or .NET Remoting if the clients are all on the same network. Another form would be a Windows Communication Foundation if your up to it.
only two letters away from being an asset
|
|
|
|
|
While playing around with a Black Jack program, I got wondering about the best way to do a decision matrix in C#.
What I am thinking of is basically a 2 dimensional matrix with each row/col combination containing a value representing 1 of a number of different options (e.g. Hit, Stand, Double, Split, etc).
Is a 2 dimensional array the best way to implement it, or is there a better method?
Any opinions?
David Wilkes
|
|
|
|
|
amatbrewer wrote: While playing around with a Black Jack program, I got wondering about the best way to do a decision matrix in C#.
What I am thinking of is basically a 2 dimensional matrix with each row/col combination containing a value representing 1 of a number of different options (e.g. Hit, Stand, Double, Split, etc).
Is a 2 dimensional array the best way to implement it, or is there a better method?
That seems pretty elegant to me, but what you're proposing is only good for evaluating the 1st move of the hand. If one axis represents what the dealer is showing, and the other axis represents what you have showing, it's a very fast lookup of what to do.
After the first move, you either need to code a more traditional if {} else {} type code construct, or have another decision matrix, since you don't have options like splitting and doubling-down available to you after the first decision...
The pure decision matrix approach scores higher for me than the if {} else {} construct for your purpose because:
1) Once the array is initialized, evaluating decisions is very, very fast
2) If you structure your code properly, your intentions are perfectly clear. You cannot mess up the logic.
Pseudo-code:
enum Action {
Hit = 0,
Stand = 1,
DD = 2,
Split = 3
}
private static Action[][] _decision = new Action[][]
{ new Action[] */ 2 */ { Hit, Hit, Stand, DD, Hit, ... },
new Action[] { Hit, Hit, Stand, Hit, DD, ... },
.
.
.
new Action[] { Stand, Stand, Stand, Stand, ...}
}
private static Action Decision(Int32 dealerShow, Int32 meShow) {
return _decision[meShow - 2][dealerShow - 2];
}
Share and enjoy.
Sean
|
|
|
|
|
Thanks for the reply!
Blackjack got me thinking about it, but I can think of a number of projects (current and proposed) that this could be useful for.
I appreciate your example; it is much more elegant then what I was originally thinking of. Not sure I understand the syntax of “Action[][] _decision” and “private static Action Decision(Int32 dealerShow, Int32 meShow)” but it gives me something to research.
Thanks again!
David Wilkes
|
|
|
|
|
|
I have an application that creates Word documents. I can create and close any number of documents while in the application. But when a document is created in my application and another is created outside of the application, exiting both leave the instance of Word running the task manager.
After some investigation, I noticed that launching Word creates a new instance and obviously an associated PID value shows up in the Task Manager. Launching Word again just adds another handle to the initial Word process, not another instance to the Task Manager; thus the PID has two handles to Word documents.
When you exit one of Word documents, the handle remains (OpusApp?) and is enabled but not visible. Still two handles, but one is visible and the other is not. When the last Word instance is exited, everything is cleaned up, all handles of Word are release, and the process is removed from the process manager.
My problem is this:
I create a word document in my application (new PID)
I go outside the my application and launch Word (i.e. Start Menus->Word)
I now have one entry in the Task Manager (from my application) and the second Word document is attached to it with a new handle.
I close the second Word document, the document closes, but the handle remains enabled, but not visible.
When I close the document I created, Word remains in the Task Manager because I’m checking (application.documents.count) to see if there are anymore instances of word documents out there and there is because this handle is still hanging around in the instance I create even though its not active.
Is there a better way of doing this? Or checking that documents are visible?
Am I just way off base?
Thanks,
Eric
|
|
|
|
|
I had same problem before.
This is what I have to do to close the document and application so the instance won't be in task manager. I am not so sure how you are closing your document.
I close word document programmatically thought.
public void CloseMSWord()
{
msWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
msDoc.Saved = true;
msDoc.Close(ref msfalse, ref optional, ref optional);
msWord.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
msWord.Quit(ref optional,ref optional,ref optional);
msWord = null;
}
Sinc I'm only using word applicatino one at a time, I make sure the Word process is not running in task manager by using following code.
public void KillProcessByName(string processorName)
{
try
{
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName(processorName);
for(int i=0 ;i
|
|
|
|
|
pnpfriend,
Thanks for the reply. I'll give it a try.
Regards,
Eric
|
|
|
|
|
Your image is a bit small, can't tell waht you are pointing out or what you mean.
only two letters away from being an asset
|
|
|
|
|
sorry:
http://img105.imageshack.us/my.php?image=pointerua1.jpg
|
|
|
|
|
Hi
I am trying to get the list of cells that contain Today(), curretPath, filename function.
Following is my code to get the list of all the formulars on the sheet.
formularRange = excelSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeFormulas,Excel.XlSpecialCellsValue.xlNumbers);
if((bool)formularRange.Cells.HasFormula)
{
System.Array formulars;
if((bool)formularRange.Cells.HasArray)
formulars = (System.Array)formularRange.FormulaArray;
string colname = formularRange.Cells.Name.ToString();
}
Hope this help.
thanks
-- modified at 17:52 Wednesday 30th May, 2007
|
|
|
|
|
Error
------------
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
-------------
i try to use this code
but i have error
***************
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main()
{
// Create a request for the URL.
WebRequest request = WebRequest.Create("https://isp.paltel.net/login.cfm");
// If required by the server, set the credentials.
request.PreAuthenticate = true;
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// Display the status.
Console.WriteLine(response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Cleanup the streams and the response.
reader.Close();
dataStream.Close();
response.Close();
Console.Read();
}
}
}
***************
Palestine
|
|
|
|
|
Please don't re-post your question. Did you check out the
HttpWebRequest.ClientCertificates ?
Thanks,
Ben
|
|
|
|
|
Well i want to run a report for a specific record for which i have gotton help from code project but some part the that code gives Error.I am using Visualstudion.Net 2003 C#. the code is
//Instantiate variables
ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
//Set instances for input parameter 1 - @vDepartment
paramField.Name = "@vDepartment";
//Below variable can be set to any data present in SalseData table, Department column
paramDiscreteValue.Value = "South";
paramField.CurrentValues.Add(paramDiscreteValue);
//Add the paramField to paramFields
paramFields.Add(paramField);
crystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(@"..\..\..\Reports\SalseReport.rpt");
//Load the report by setting the report source
crystalReportViewer1.ReportSource = reportDocument;
the bold instructions are the errors .Actually in VS2003 we don't have obj.Name() and obj.CurrentValues.Add() functions but obj.Set_ParameterName() and Set_ParameterCurrentValues() function. when i used these instead of these,it gave me error saying that function can not be called explicitly or invalid call access operator.
waiting for everyone's solution. thank you
-- modified at 12:46 Saturday 2nd June, 2007
By Lucky Hamad
|
|
|
|
|
Hi!
i want to sort an array containing DateTime of this format: 4/5/2007 8:43:34 PM, in ascending order, i.e. latest date/time on top...
Please give any ideas about this issue...
Thanks in advance...
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
Probably a better method exists, you can anyhow try this.
Store the dates in binary format in an ArrayList. Do an ArrayList.Sort() and Arraylist.Reverse(); .
You can store date in binary using .ToBinary(); method and retrieve using DateTime.FromBinary(longDate) method.
|
|
|
|
|
If they are DateTime s then they will sort as stated.
If they are string s, they won't.
|
|
|
|
|
Hi,
since DateTime implements IComparable interface, you can do:
DateTime[] dt...;
Array.Sort(dt);
If it did not implement IComparable (or you want a different order), you would have
to provide a Comparer object as is:
public class DTComparer : IComparer {
public int Compare(object odt1, object odt2) {
DateTime dt1=(DateTime)odt1;
DateTime dt2=(DateTime)odt2;
long diff=dt1.Ticks-dt2.Ticks;
if (diff<0) return -1;
if (diff>0) return 1;
return 0;
}
}
public void demo() {
DateTime[] dt=new DateTime[]{
DateTime.Now.AddDays(1),
DateTime.Now.AddMinutes(1),
DateTime.Now.AddHours(1)
};
log(dt);
Array.Sort(dt, new DTComparer());
log(dt);
}
public void log(DateTime[] dta) {
log("DateTime[]:");
foreach (DateTime dt in dta) log(" "+dt.ToString());
}
|
|
|
|
|
Hello Luc,
It's allways a pleasure reading your explanation!
All the best,
Martin
|
|
|
|
|
|
Luc,
Thanks alot for the help, it solved my problem...
Looking forward for more help from you in future...
cheers!
Regards,
Affan Ahmad Toor
..................
QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!
|
|
|
|
|
I am in a small project about an application about storing, monitoring and pricing orders. I am completely in charge of the project (from analysis to tests) and I have 3 months in total to complete it (so think of about 1+ month of programming and some more weeks of fixing bugs and adding features during the test period) with 30 hours/week at most.
The company is small. The budget for new technologies is almost inexistent (they will barely afford to increase server's ram from... 128MB(!) and possibly upgrade an old win2000 machine). They want a specialised client fitted to their (quite limited) needs.
I know C# and ASP.NET (not an expert, but I do have experience in various projects). As the users will be few and non-concurrent, ASP.NET was simply not worth the effort (they are not thinking of working over internet).
I could have a simple Access database (back end) and leave to the chief manager a front end with graphs+reports on how to make his own graphs to observe whatever he wants to, and do all the rest of the application in c# clients.
But some advised me of doing everything in Access Forms. I checked this a bit more, and show that possibly Data Access Pages is a better idea. The questions are:
-are Data Access Pages going to be faster in the development? They seem so with their close integration to access, but then i fear that messing with VBScript will slow down the process (I dislike scripting languages)
-is Excel integration (as it will be helpful for pricing) in Data Access Pages strong enough to make up for the lost advanced GUI functionality I can have with WinForms?
In both cases some pretty advanced (think of DataRepeaters on drugs) functionality will be welcome if it's easily implemented.
The back end database could be used with other clients even if the company expands within reason (turning from micro to large is not even in the business plans).
--Victory, Not Vengeance
|
|
|
|
|