|
I've tested the Directory.Exists method and it definitely has no problem with space characters within folder names. At least that the case in a windows application, but I doubt the behaviour changes in an installer. Also it is not specified that the method throws any exception; it simply returns a boolean value.
What statement throws the IO exception?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi ! I have to create a new software in C# which will always RUN in the background. I want to show the GUI only when the user click on the icon in the icon tray (resident program). The program must run by itself each time the system (PC) is power up.
How we do it ?
Note: I have checked with my Visual Studio 2005 in the New Project option but I don't see anything that seems to be a SERVICE (or resident program).
How I must create the project ????
Thank you.
Danny Gilbert, engineer
Montreal, Canada
|
|
|
|
|
Create a new Project, and in the Project Types treeview, select "Windows" and then "Windows Service".
You'll probably want to make 2 programs. The service itself, and then a small Windows app to act as an interface for it.
|
|
|
|
|
Hey guys, i have a thread i created that loops in a while loop it also has 3 functions in it:
1 being:
private void PrintRecord()
I set up a delegate in the thread so that when the delegate is called it "should" make the thread do this function. When it does it still "hangs" the main form and it should really do the work behind the scenes without interupting the main form. Can someone point me in the right direction to what i am doing wrong?
Thanks In Advance,
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Please post the relevant code. Help us to help you.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thank you for the reply. Below is what i have going on:
This is where i create the thread
m_objPrintThread = new PrintThread(m_objUV, this, m_sRecKey, m_DailyRec);
m_objPrintThreadID = new Thread(m_objPrintThread.ThreadStart);
m_objPrintThreadID.Start();
This is what is basically going in the thread. There are three functions I only put one in here to save space.
namespace CashRec
{
public delegate bool PrintCashRec();
class PrintThread
{
UONET m_objUV;
string m_sKey, m_sRec;
frmMain m_form;
volatile bool m_bShouldStop = false;
public PrintCashRec m_PrintRec;
public PrintThread(UONET objUV, frmMain form, string sKey, string sRec)
{
m_form = form;
m_objUV = objUV;
m_sKey = sKey;
m_sRec = sRec;
m_PrintRec = new PrintCashRec(Print);
}
public void ThreadStart()
{
while (!m_bShouldStop)
{
Thread.Sleep(500);
}
}
public void ThreadStop()
{
m_bShouldStop = true;
}
private Boolean Print()
{
bool bSuccessful = false;
while (!bSuccessful)
{
}
return bSuccessful;
}
Here basically i am calling the delegate and i would expect it to just signal the thread to call the print function without it hanging the main form. But it still hangs the form.
private void mnuPrint_Click(object sender, EventArgs e)
{
if (m_objPrintThread == null)
{
if (StartPrintThread())
m_objPrintThread.m_PrintRec;
}
else
m_objPrintThread.m_PrintRec;
}
Thanks again for your help
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
As a quick answer, it seems to me that you are calling a not-threaded method, while the threded one does nothing (only sleeps). But I'm in hurry hence I can't give a better look at your code. Maybe tomorrow you'll get a better answer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Is the objective of your code to display a record to a control on the main form? If so you need a different approach to the problem so check out the InvokeRequired property of forms.
Phil
|
|
|
|
|
what the thread does is prints documents to a printer. Reason why i have it in a thread is it builds the record to print. If i did this on the main thread it would lock up the GUI for about 10/20 seconeds which is would make the user think that the program is locking up. What i did as a work around is create 3 flags in the thread. Every 1 seconed it will loop and check for those flags and if one is true it will do the function that corresponds to that flag. It does work fine but i don't think it is the right approach.
Thanks for the reply,
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
In that case, my preference would be to do the following:
Create a queue of some type (Look up "Queue") to which the records to be printed will be added. Also create an auto reset event that can be signaled each time a record is added to the queue. Finally, create and start the print thread.
When the user wants to print, the print process can queue the record and signal the auto reset event that there is a record to print.
The print thread should do the following:
In a loop the thread must wait until signaled.
Check if the application is shutting down and if so, exit the loop.
In a loop, inside the loop mentioned above, pop the first record off the queue and print it until there are no more records in the queue to print.
Of course you will have to lock the queue when adding records and also when popping the records off for printing so that the queue does not get corrupt.
This will allow the printing to occur in a separate thread from the GUI thread which will allow the GUI to respond to user input.
Phil
|
|
|
|
|
Hi all,
i have a problem, i need playing mp3 from stream (stream nor mp3 file from my hdd) but i dont now how .
I hope anybody can help me with this problem.
|
|
|
|
|
I am trying to create a simple I/O program for use with a usb joystick I have. I want it to just respond by showing what input it is receiving, for example displaying "A" if the "A" button is pressed or displaying "up left" if the joystick is held up left. I just need a little help getting started. I am using Visual C# 2005, so if anyone knows how to do this, I would sure appreciate it.
ALEX
-- modified at 13:38 Wednesday 28th February, 2007
|
|
|
|
|
|
Thank you I will look into these sites.
|
|
|
|
|
The easiest way is to use DirectX and it's DirectInput subsystem.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Webservice returns a method of generic collection type i.e. List<marketvaluetypes.forward>
i.e:
[WebMethod()]
public List<marketvaluetypes.forward> MarketValuesForwardsGet(int intMarketValueTypeID, int intIndexID, DateTime dtDateValue)
{
try
{
return Business.MarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
}
catch
{
throw;
}
}
from the client side i.e. form, I would like to retrieve the collection. This is what I am doing
private void btnMarketValues_Click(object sender, EventArgs e)
{
List<marketvaluetypes.forward> forwards = null;
int intMarketValueTypeID = int.Parse(cboMarketValueTypes.SelectedValue.ToString());
int intIndexID = int.Parse(cboIndices.SelectedValue.ToString());
DateTime dtDateValue = DateTime.Parse(dtpValueDate.Value.ToShortDateString());
private MarketDataService.MarketData wsMarketData;
wsMarketData = new MarketDataService.MarketData();
//this line gives the error
forwards = wsMarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
//
foreach (MarketValueTypes.Forward f in forwards)
{
}
}
The error message is:
Cannot implicitly convert type 'MarketDataService.Forward[]' to 'System.Collections.Generic.List<marketvaluetypes.forward>'
Thanks
|
|
|
|
|
I think you need to read up a little more on generic lists. The defination of a generic list would look like:
List<forward>
You are passing back an array of Forward which is not an generic list. So if you change your List to a List<forward> you will at least be in a little better shape. I have not tried to return a generic list in a web service, so I am not sure what issue may come from that. I know that what ever is returned from a web service needs to be serializeable.
Anyway, hope that helps.
Ben
|
|
|
|
|
Could you please let me know exactly where/what to change this in the code please? i.e. please modify the code.
Thanks
|
|
|
|
|
You don't have all your code listed so I won't be able to make all the changes, but the webmethod should look like this:
[WebMethod()]
public List<forward> MarketValuesForwardsGet(int intMarketValueTypeID, int intIndexID, DateTime dtDateValue)
{
try
{
return Business.MarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
}
catch
{
throw;
}
}
Assuming that your generic collection is of type Forward.
In your MarketValuesForwardsGet you will need to return a List<forward> as well.
Ben
|
|
|
|
|
Apologiese but I think I am doing just that.
may be I am not following you correctly.
Is there anything else from the code you would like me to send you?
Thanks
|
|
|
|
|
Sorry I didn't do the <> signs right so they were removed from my previous post.
You don't have all your code listed so I won't be able to make all the changes, but the webmethod should look like this:
[WebMethod()]
public List<Forward> MarketValuesForwardsGet(int intMarketValueTypeID, int intIndexID, DateTime dtDateValue)
{
try
{
return Business.MarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
}
catch
{
throw;
}
}
Assuming that your generic collection is of type Forward.
In your MarketValuesForwardsGet you will need to return a List<Forward> as well.
Ben
|
|
|
|
|
But this is exactly what I have in the webservice as i explained in the first post. Am I not right?
Thanks
|
|
|
|
|
Perhaps the <Forward> was removed from your orignal post as well?
List
is not the same as
List<Forward>
You error message that you are getting is this:
MarketDataService.Forward[]
That is an array of Forward, not
List<Forward> which is a generic collection.
Sorry about the confusion.
Ben
|
|
|
|
|
Ok, this is what I have:
[WebMethod(Description = "Get MarketValues for ForwardCurves")]
public List<forward> MarketValuesForwardsGet(int intMarketValueTypeID, int intIndexID, DateTime dtDateValue)
{
try
{
return Business.MarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
}
catch
{
throw;
}
}
in the form:
private void btnMarketValues_Click(object sender, EventArgs e)
{
List<forward> forwards = null;
int intMarketValueTypeID = int.Parse(cboMarketValueTypes.SelectedValue.ToString());
int intIndexID = int.Parse(cboIndices.SelectedValue.ToString());
DateTime dtDateValue = DateTime.Parse(dtpValueDate.Value.ToShortDateString());
//error here////
forwards = wsMarketData.MarketValuesForwardsGet(intMarketValueTypeID, intIndexID, dtDateValue);
///
foreach (Forward f in forwards)
{
}
}
|
|
|
|
|
When you posted this did you click the Ignore HTML tags in this message check box at the bottom? If you didn't please check it and post your code again.
Thanks,
Ben
|
|
|
|