|
yes, you are right. I looked at the code & found that in the StartListening method there is a while(true) loop in which there is a WaitOne call.
any ideas how can I resolve this ? Should I call the StartListening method in a seperate thread from the ServiceMain (OnStart) function ?
Any ideas will be of gr8 help.
Thanks
|
|
|
|
|
There is no need to start a seperate thread. Since you are using an asynchronous socket you can easily start listening. The while-loop with the waitone is in the example program, because the application will stop when the main-method ends. Since the service is running as long it is not stopped, the socket will listen also. So you should remove the while-loop with the wait-statement. Don't forget to close the socket when the service stops.
Regards
Sebastian
|
|
|
|
|
Hi Sebastian,
Thanks for your reply.
Sorry, but in a hurry I missed some additional explanation regarding my requirement.
I have Edited my post accordingly.
"
Additional Info:
This windows service is to act as server listening to 'n' number of socket clients connecting & sending data."
I guess if I remove the while loop the service will be able to accept only one connection & any other client will not be able to connect.
My windows service has to keep listening to client socket connection that can happen at any time & process the data that client passes.
Hence I guess the while loop will be required.
Also I read a little about WaitOne in MSDN & it is for thread synchronization incase more than 1 client tries to connect simultaneously.
Any ideas ?
Thanks.
|
|
|
|
|
Yes, the WaitOne is for thread synchronization. If I get the idea of the Asynchronous Socket right the socket waits for a client to connect. If a client connects the event handler is called. Within the example the event handle calls a "EndAccept". So I guess, if you call listener.BeginAccept afterwards the listener-socket is ready for the next client to connect.
By the way, did you checked the TcpListener class. I think using this class in a seperate thread will be easier than using this asynchronous socket...
Regards
Sebastian
|
|
|
|
|
HELLO Experts,
Actually I want to Create PDF OF ALL PRINTING DOCUMENTS. SO I WANT TO CREATE A PRINTER DRIVER FOR DOING THIS.
SO PLEASE HELP ME FOR CREATING PDF FILE BY USING VB.NET OR C#.
THANKS A LOT
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: Actually I want to Create PDF OF ALL PRINTING DOCUMENTS.
Please don't shout
eg_Anubhava wrote: SO PLEASE HELP ME FOR CREATING PDF FILE BY USING VB.NET OR C#.
I'm afraid that's not possible. Device Drivers[^] are written in native, not in managed code.
I are Troll
|
|
|
|
|
Do u have any idea for Converting any document (Like : Word,Notepad) to PDF Format.
If you can think then I Can.
|
|
|
|
|
|
I thought I'd have a play with Enterprise Application Blocks (an add-on for VS2008 from Microsoft). But I'm getting something odd.
I installed it (v4.1), added the necessary references to my project, and used the Enterprise Library Configuration tool to set up a simple ExceptionHandler with logging. Then to test it I hard-wired a divide-by-zero error into my application code (inside a try-catch block). Everything compiles okay but when I get to the deliberate error it crashes with a message about not being able to load an assembly due to a mismatch in the manifest.
I tried different ways of referencing the DLLs and cleaned the solution but without success. But then I found if I manually edit the app.config (which the Enterprise Library Configuration tool modifies) and remove the version, culture, and public key token from all the 'type' attributes ... it works! (I noticed the supplied QuickStart samples didn't have this in their app.config which is what led me to try the same in my application. Also, an eyeball check of the DLL metadata implied I have the correct versions.)
Thing is, every time I go back into the Enterprise Library Configuration tool it adds these bits back in. Am I doing something wrong or is this a bug in the tool? Anyone else have experience of this?
|
|
|
|
|
hi,
I am using entity data model and i have master-detail scenario.(Patient-PatientAddresses)
Everything is going on fine if i am updating any data either in master table or detail table.
But when i am going to insert a new detail record while updating master entity, it gives me following error :
"An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key."
I googled so much, but not getting proper idea.
Here is my code :
using (var context = new Entities())
{
try
{
var record = (from p in context.Patient.Include("PatientAddress")
where p.PatientId == patient.PatientId
select p).FirstOrDefault();
if (record == null)
{
context.AddToPatient(patient);
}
else
{
foreach (var item in patient.PatientAddress)
{
if (item.EntityKey == null)
{
context.AddToPatientAddress(item);
continue;
}
context.ApplyPropertyChanges("PatientAddress", item);
}
context.ApplyPropertyChanges("Patient", patient);
}
context.SaveChanges();
return true;
}
catch
{
return false;
}
}
Any suggessions is appreciated.
modified on Wednesday, February 3, 2010 9:55 AM
|
|
|
|
|
Fix your post. The code is unreadable.
|
|
|
|
|
Sorry but i can read it from here.
Can you tell me which lines of the code you are not able to read?
|
|
|
|
|
It's OK now. The first time I looked at it, the entire code snippet was on a single line and you had to scroll left and right to read it all.
|
|
|
|
|
|
Ohhh really??????
Thanks a lot.
|
|
|
|
|
Hello friends,
I wants to generate popup in my windows application after every 5 minutes of some events.
I am using Timer Control for that but i don't get accurate result and Continuous execution of timer ticks hangs the Computer.
I have also tried make one service but it does not allow any user interface
with that.
i am very confused.
Please help
Thanks.
RAHUL.
E-mail:rahulpatel112@gmail.com
|
|
|
|
|
The Timer is not 100% accurate and differences CPU cycles, ticks, etc. can throw it off slightly, but it shouldn't be that much of a problem for this usage. If you need absolute precision then create a Thread and use something like GetTickCount
I know the language. I've read a book. - _Madmatt
modified on Wednesday, February 3, 2010 9:02 AM
|
|
|
|
|
a wild guess as you didn't show any code, nor provided any hard facts: timer intervals are specified in milliseconds, not seconds; your number is just too small.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Luc Pattyn wrote: your number is just too small
It's a common complaint, and judging by the amount of spam in my spam folder, it's easily curable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
November Uniform
would you perhaps need new spectacles?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I set interval to 5000(5 seconds)
i think it's not small number.
What u say?
|
|
|
|
|
You still haven't provided any code, so it's impossible to tell you what's wrong.
|
|
|
|
|
First of all thanks a lot.
Now problem is
In coding I have time filed which stores current time when there is some events happen.
i wants to generate popup after(5 minutes) time reaches at
time=time + 5minute.
so after every 5 seconds in timer's tick event i am checking,Is time has reached the limit.if it is then generate popup.
This is the coding which i am doing.
<br />
if (System.DateTime.Now.ToShortTimeString() >= Actualtime.AddMinutes(5) )<br />
{<br />
frm_grcprd_popup obj_popup = new frm_grcprd_popup();<br />
obj_popup.lbl_Visitor_Id.Text = id[i].ToString();<br />
obj_popup.Show();<br />
}<br />
There are some more database operation is there to show values on popup.
thats it.
|
|
|
|
|
You must show us the relevant code (in PRE tags!) for us to be able to help you.
A simple action that occurs every 5 seconds would not "hang the Computer" unless you have some mistake in there.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
hi guyz...
-> i need some good articles or help regarding bluetooth programming in dotnet... i am also searching
the web but i am unable to find good one... plz help me out with this...
thanks...
take care...
J A Nasir K
|
|
|
|