|
Hi guys,
Please help! I have a windows service when started it goes out and retrieves a schedule from the database and stores it into a string array. Once the schedule is retrieved. I start my timer which calls the following code:
Every 45 seconds I am running MonitorFunc which checks whether the schedule is now to run a query. The question I have is whether the code section below is a good process that I am going by. Please help.
try
{
m_tMonitor = new TD.Timer(new TD.TimerCallback(MonitorFunc),1, 0,45000);//45 sec
if(m_sServerAddr==string.Empty)
{
m_sServerAddr=Dns.GetHostName();
}
if(m_nPort==-1)
{
m_nPort=1024;
}
IPHostEntry hostEntry=Dns.Resolve(m_sServerAddr);
IPAddress ipAddress = hostEntry.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,m_nPort);
m_svSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
m_svSocket.Bind(ipEndPoint);
m_svSocket.Listen(10);
while(true)
{
Socket rtSocket=m_svSocket.Accept();
if(rtSocket.Connected)
{
TD.WaitCallback myCallBack = new TD.WaitCallback(ProcessClientRequest);
TD.ThreadPool.QueueUserWorkItem(myCallBack,rtSocket);
}
}
}
catch(Exception ex)
{
m_svSocket.Close();
m_tMonitor.Dispose();
}
Sameer
|
|
|
|
|
I'm suffering some issues at deployment time which seem to relate to various dlls etc not being available.
Is their a CLR version of the old depends tool that used to ship with visual studio? ie a tool that shows me which dependencies are broken rather than what the mainfest says the dependencies are?
Thanks
Russell
|
|
|
|
|
Reflector? It allows you to view the references, normally if it's in the path or the GAC then it can find it.
|
|
|
|
|
You don't need it. There is a Assembly Binding Log Viewer tool that tells you what happened.
In the MSDN docs, lookup "Fuslogvw.exe", or just Google for it.
|
|
|
|
|
brilliant thank you.
I'd completely forgotten about fuslog
|
|
|
|
|
I need to bind a textbox's text to an xmlElement's value.
<br />
TextBox tb;<br />
XmlNode nodeToBind;<br />
tb.DataBindings.Add("Text", nodeToBind, "Value");<br />
results in an ArgumentException (Property or Column for the datasource cannot be bound. parametername: dataMember).
any hints?
|
|
|
|
|
Hello,
I'm building an application which has an option to play a sound with the extern PlaySound method.
With the code below the PlaySound method is working
<br />
string fileName = @"C:\Documents and Settings\User\My documents\Visual Studio 2005\Projects\Alarm\Alarm\Resources\attention.wav";<br />
PlaySound(fileName, 0, 1);<br />
If I execute the program on an other computer the path will be different. So I need an function that will get the .wav file from my folder Resources. The standard way to access an embedded resource is to use the Assembly class's GetManifestResource* methods. But I can't get it to work properly.
This is proberly a very stupid question but i'm just a beginner and can't figure it out.
Can someone please help me out?
Thanks
|
|
|
|
|
JustRonald wrote: But I can't get it to work properly.
JustRonald wrote: but i'm just a beginner and can't figure it out.
If you are getting some error message you need to post that along with the relevant code. Read the first post in the forum titled "How to get an answer to your question".
led mike
|
|
|
|
|
There's an example here[^]
The only problem I've found is you need to specify the file's location as
"yournamespace.Resources.filename.ext"
e.g.
GetManifestResourceStream("My_App.Resources.new.wav");
Edit: You needto use Winmm.dll not Coredll.dll
Improved solution/example below
Dave
modified on Monday, March 3, 2008 2:51 PM
|
|
|
|
|
|
I thought this was something interesting that I could maybe use so I've had a play and the example below works (ringin.wav from C:\Windows\Media added to resources and BuildAction property set to Embedded Resource).
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Load += new EventHandler(Form1_Load);
}
void Form1_Load(object sender, EventArgs e)
{
Stream wave = Assembly.GetExecutingAssembly().
GetManifestResourceStream(
MethodBase.GetCurrentMethod().
DeclaringType.Namespace + ".Resources." + "ringin.wav");
Byte[] waveData = new Byte[wave.Length];
wave.Read(waveData, 0, (int)wave.Length);
PlaySound(waveData, IntPtr.Zero, SoundFlags.SND_ASYNC | SoundFlags.SND_MEMORY);
}
enum SoundFlags
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_MEMORY = 0x0004,
SND_NODEFAULT = 0x0002,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}
[DllImport("winmm.dll")]
static extern bool PlaySound(byte[] pszSound, IntPtr hmod, SoundFlags fdwSound);
}
}
I've used SoundFlags.SND_ASYNC as it's in the load event but if you want it in FormClosing for example use SoundFlags.SND_SYNC
Dave
|
|
|
|
|
Hi Ronald,
there are some ways to solve your problem:
1. you can distribute your wav file in a specific subfolder of your application, e.g. Sounds. Then you just set the filename variable to the following value:
string filename = Application.StartupPath + @"Sounds\attention.wav";
Don't forget to include using System.Windows.Forms. or type the namespace with the Application.StartupPath
2. You add the audio file as manifest into your exe. Then you need to call the following function:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program), "attention.wav")
Note that you get a System.IO.Stream , so maybe need to save it in a temporary file and then call your PlaySound method (I don't know if your function supports a stream object as a parameter)
So, these are the ways, I retrieved quickly from my mind at 23:17 (German time)
PS: In the second solution I wrote typeof(Program). Program is a class generated by VisualStudio when you create a new project, so I used this here
I hope I could help you
_____________________________
The force of .NET is with me!
|
|
|
|
|
Does anyone know/have any control like calender, but only show month and year. So the user only need to select the month and date. I'm in a hurry and don't want to create my own control. tHanks.
|
|
|
|
|
If you don't have the day in the date, then the whole calendar paradigm doesn't work. In this case, you're better off with 2 combos. One for month and one for year.
|
|
|
|
|
Thank for the quick reply. But I'm hoping to find somebody who have made control consisting of two combobox , one for month and one for year.
|
|
|
|
|
To be honest, it'll take you longer to wait for the reply than it would to code it yourself. It's effectively two databound combos, so why not do it yourself.
|
|
|
|
|
Well, good idea. I'm starting to doing it by myself. It isn't as hard as I thought it will be.
|
|
|
|
|
Yulianto. wrote: I'm starting to doing it by myself. It isn't as hard as I thought it will be.
That's the spirit.
|
|
|
|
|
|
fellas
i was wondering if i could pull something out of a text file at a given index, i can pull a certain amount of char's like this code, i want to pull a full line like you would when pulling something out of a list box like selecteditems(0) and so fore
TextReader myFile= new StreamReader("file.txt");
string index = myFile.ReadToEnd().Remove(51);
that will remove the first 51 chars, which is the length of the first line but how would i do second and third line or if they were longer than 51 chars
anybody got any ideas
thanks for any help
j2s
|
|
|
|
|
using (System.IO.StreamReader sr = new System.IO.StreamReader(@"c:\data.txt"))
{
sr.BaseStream.Position = 5;
sr.Read();
MessageBox.Show(sr.ReadLine());
}
Why don't you store the lines in string[] or something, so that you read the file once.
string[] lines = System.IO.File.ReadAllLines(@"c:\data.txt");
Eslam Afifi
modified on Monday, March 3, 2008 12:22 PM
|
|
|
|
|
how to add database fields to a crystal report in .net 2005
in code instead open Window field explorer and menu database expert
|
|
|
|
|
Hello,
I have a question regarding a row selection of the datagridview control.
How can I prevent that the user can click on another row than the row where my current cell is (in editing mode)
So I have a row with 4 cell's for example, the row is selected, and the first cell is in editing mode.
When I click another row other than the one I'm editing, the focus goes to this other row.
How can I prevent that in code?
Thank you!
Greetings
|
|
|
|
|
use this, to know about editing mode
DGV[ColumnIndex, RowIndex].IsInEditMode
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thank you,
I can figure out if the cell is in edit mode, but if this is true, I may not be able to select other rows than the row where my editing cell is in .. ?
Is there a way I can do that?
Thanks
|
|
|
|