Hello
Can someone please tell me what I'm doing wrong? I'm writing an application
that should be using callbacks to perform asynchronous calls to the Win32
API. Problem is it never reaches my callback function. Any feedback is
appreciated. Also, any references to websites with examples of .NET async
multithreading would be appreciated. Thanks in advance.
public serverInfo getSession(string servername)
{
serverInfo svInfo;
Object stateObj = new Object();
delGetServer x = new delGetServer(getServer);
IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new
AsyncCallback(finishedProc), stateObj);
return (svInfo);
}
public static void getServer(string servername, out serverInfo svInfo)
{
// performs Win32 API calls to get server info. on network
}
public delegate void delGetServer (string s1, out serverInfo svInfo);
public static void finishedProc(IAsyncResult ar)
{
serverInfo svInfo;
delGetServer temp = (delGetServer)ar.AsyncState;
temp.EndInvoke(out svInfo, ar);
} 6 2281
Hi, Michael
Problem is that code is not complete. If you use asynch invoke like this one
[C#]
public IAsyncResult BeginInvoke(
object target,
object[] values,
AsyncCallback callback,
object asyncState
);then there are some differences in syntax. I would suggest to put tracers
in called methods to see process flow. Might happen your called delegate
really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net> wrote in
message news:hZ*********************@news4.srv.hcvlny.cv.n et... Hello
Can someone please tell me what I'm doing wrong? I'm writing an
application that should be using callbacks to perform asynchronous calls to the Win32 API. Problem is it never reaches my callback function. Any feedback is appreciated. Also, any references to websites with examples of .NET async multithreading would be appreciated. Thanks in advance.
public serverInfo getSession(string servername) { serverInfo svInfo; Object stateObj = new Object(); delGetServer x = new delGetServer(getServer); IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new AsyncCallback(finishedProc), stateObj); return (svInfo); }
public static void getServer(string servername, out serverInfo svInfo) { // performs Win32 API calls to get server info. on network }
public delegate void delGetServer (string s1, out serverInfo svInfo);
public static void finishedProc(IAsyncResult ar) { serverInfo svInfo; delGetServer temp = (delGetServer)ar.AsyncState; temp.EndInvoke(out svInfo, ar); }
Thanks. I'm new to multithreading in .NET. I know the Async Callback
function is not being called. What's a tracer?
Michael C
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:Ok**************@TK2MSFTNGP09.phx.gbl... Hi, Michael
Problem is that code is not complete. If you use asynch invoke like this
one [C#] public IAsyncResult BeginInvoke( object target, object[] values, AsyncCallback callback, object asyncState );then there are some differences in syntax. I would suggest to put
tracers in called methods to see process flow. Might happen your called delegate really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net> wrote
in message news:hZ*********************@news4.srv.hcvlny.cv.n et... Hello
Can someone please tell me what I'm doing wrong? I'm writing an application that should be using callbacks to perform asynchronous calls to the
Win32 API. Problem is it never reaches my callback function. Any feedback is appreciated. Also, any references to websites with examples of .NET
async multithreading would be appreciated. Thanks in advance.
public serverInfo getSession(string servername) { serverInfo svInfo; Object stateObj = new Object(); delGetServer x = new delGetServer(getServer); IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new AsyncCallback(finishedProc), stateObj); return (svInfo); }
public static void getServer(string servername, out serverInfo svInfo) { // performs Win32 API calls to get server info. on network }
public delegate void delGetServer (string s1, out serverInfo svInfo);
public static void finishedProc(IAsyncResult ar) { serverInfo svInfo; delGetServer temp = (delGetServer)ar.AsyncState; temp.EndInvoke(out svInfo, ar); }
Michael,
tracer = Console.WriteLine or Debug/Trace calls.
delGetServer temp = (delGetServer)ar.AsyncState should be changed to
ar.AsyncDelegate. You try to get delegate from state, which doesn't work.
You can't see exception, because you don't have try/catch and execute on
another thread.
And I have slight suspicion that finishedProc is called once again by
EndInvoke. Check if EndInvokeCalled and IsCompleted too.
HTH
Alex
"Michael C" <mi*******@optonline.net> wrote in message
news:Ju*********************@news4.srv.hcvlny.cv.n et... Thanks. I'm new to multithreading in .NET. I know the Async Callback function is not being called. What's a tracer?
Michael C
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:Ok**************@TK2MSFTNGP09.phx.gbl... Hi, Michael
Problem is that code is not complete. If you use asynch invoke like this one [C#] public IAsyncResult BeginInvoke( object target, object[] values, AsyncCallback callback, object asyncState );then there are some differences in syntax. I would suggest to put tracers in called methods to see process flow. Might happen your called delegate really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net> wrote in message news:hZ*********************@news4.srv.hcvlny.cv.n et... Hello
Can someone please tell me what I'm doing wrong? I'm writing an application that should be using callbacks to perform asynchronous calls to the Win32 API. Problem is it never reaches my callback function. Any feedback
is appreciated. Also, any references to websites with examples of .NET async multithreading would be appreciated. Thanks in advance.
public serverInfo getSession(string servername) { serverInfo svInfo; Object stateObj = new Object(); delGetServer x = new delGetServer(getServer); IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new AsyncCallback(finishedProc), stateObj); return (svInfo); }
public static void getServer(string servername, out serverInfo svInfo) { // performs Win32 API calls to get server info. on network }
public delegate void delGetServer (string s1, out serverInfo svInfo);
public static void finishedProc(IAsyncResult ar) { serverInfo svInfo; delGetServer temp = (delGetServer)ar.AsyncState; temp.EndInvoke(out svInfo, ar); }
Thanks for the help. I finally got it working. Only one problem - not all
of my threads are being killed after they do their job. After returning
their info., I'm consistently stuck with 5 or 6 threads that haven't been
killed. Any way to kill all worker threads at once?
Thanks,
Michael C.
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:eY**************@tk2msftngp13.phx.gbl... Michael,
tracer = Console.WriteLine or Debug/Trace calls.
delGetServer temp = (delGetServer)ar.AsyncState should be changed to ar.AsyncDelegate. You try to get delegate from state, which doesn't work. You can't see exception, because you don't have try/catch and execute on another thread.
And I have slight suspicion that finishedProc is called once again by EndInvoke. Check if EndInvokeCalled and IsCompleted too.
HTH Alex
"Michael C" <mi*******@optonline.net> wrote in message news:Ju*********************@news4.srv.hcvlny.cv.n et... Thanks. I'm new to multithreading in .NET. I know the Async Callback function is not being called. What's a tracer?
Michael C
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:Ok**************@TK2MSFTNGP09.phx.gbl... Hi, Michael
Problem is that code is not complete. If you use asynch invoke like
this one [C#] public IAsyncResult BeginInvoke( object target, object[] values, AsyncCallback callback, object asyncState );then there are some differences in syntax. I would suggest to put tracers in called methods to see process flow. Might happen your called
delegate really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net>
wrote in message news:hZ*********************@news4.srv.hcvlny.cv.n et... > Hello > > Can someone please tell me what I'm doing wrong? I'm writing an application > that should be using callbacks to perform asynchronous calls to the Win32 > API. Problem is it never reaches my callback function. Any
feedback is > appreciated. Also, any references to websites with examples of .NET async > multithreading would be appreciated. Thanks in advance. > > public serverInfo getSession(string servername) > { > serverInfo svInfo; > Object stateObj = new Object(); > delGetServer x = new delGetServer(getServer); > IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new > AsyncCallback(finishedProc), stateObj); > return (svInfo); > } > > public static void getServer(string servername, out serverInfo
svInfo) > { > // performs Win32 API calls to get server info. on network > } > > public delegate void delGetServer (string s1, out serverInfo
svInfo); > > public static void finishedProc(IAsyncResult ar) > { > serverInfo svInfo; > delGetServer temp = (delGetServer)ar.AsyncState; > temp.EndInvoke(out svInfo, ar); > } > >
Michael,
what do you mean by killed?
"Michael C" <mi*******@optonline.net> wrote in message
news:IN*********************@news4.srv.hcvlny.cv.n et... Thanks for the help. I finally got it working. Only one problem - not
all of my threads are being killed after they do their job. After returning their info., I'm consistently stuck with 5 or 6 threads that haven't been killed. Any way to kill all worker threads at once?
Thanks, Michael C.
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:eY**************@tk2msftngp13.phx.gbl... Michael,
tracer = Console.WriteLine or Debug/Trace calls.
delGetServer temp = (delGetServer)ar.AsyncState should be changed to ar.AsyncDelegate. You try to get delegate from state, which doesn't
work. You can't see exception, because you don't have try/catch and execute on another thread.
And I have slight suspicion that finishedProc is called once again by EndInvoke. Check if EndInvokeCalled and IsCompleted too.
HTH Alex
"Michael C" <mi*******@optonline.net> wrote in message news:Ju*********************@news4.srv.hcvlny.cv.n et... Thanks. I'm new to multithreading in .NET. I know the Async Callback function is not being called. What's a tracer?
Michael C
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:Ok**************@TK2MSFTNGP09.phx.gbl... > Hi, Michael > > Problem is that code is not complete. If you use asynch invoke like this one > [C#] > public IAsyncResult BeginInvoke( > object target, > object[] values, > AsyncCallback callback, > object asyncState > );then there are some differences in syntax. I would suggest to put tracers > in called methods to see process flow. Might happen your called delegate > really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net> wrote in > message news:hZ*********************@news4.srv.hcvlny.cv.n et... > > Hello > > > > Can someone please tell me what I'm doing wrong? I'm writing an > application > > that should be using callbacks to perform asynchronous calls to
the Win32 > > API. Problem is it never reaches my callback function. Any feedback is > > appreciated. Also, any references to websites with examples of
..NET async > > multithreading would be appreciated. Thanks in advance. > > > > public serverInfo getSession(string servername) > > { > > serverInfo svInfo; > > Object stateObj = new Object(); > > delGetServer x = new delGetServer(getServer); > > IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new > > AsyncCallback(finishedProc), stateObj); > > return (svInfo); > > } > > > > public static void getServer(string servername, out serverInfo svInfo) > > { > > // performs Win32 API calls to get server info. on network > > } > > > > public delegate void delGetServer (string s1, out serverInfo svInfo); > > > > public static void finishedProc(IAsyncResult ar) > > { > > serverInfo svInfo; > > delGetServer temp = (delGetServer)ar.AsyncState; > > temp.EndInvoke(out svInfo, ar); > > } > > > > > >
I think I might have solved this one. I think I was recreating new
delegates when I was trying to kill the previous ones (i.e., stop them from
running). Sorry about the lingo - I forgot killing threads is what you do
on UN*X. I was just wondering if there was a way to force all the worker
threads to stop running at one shot, through a single instruction?
Thanks,
Michael C.
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Michael,
what do you mean by killed?
"Michael C" <mi*******@optonline.net> wrote in message news:IN*********************@news4.srv.hcvlny.cv.n et... Thanks for the help. I finally got it working. Only one problem - not all of my threads are being killed after they do their job. After returning their info., I'm consistently stuck with 5 or 6 threads that haven't
been killed. Any way to kill all worker threads at once?
Thanks, Michael C.
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message news:eY**************@tk2msftngp13.phx.gbl... Michael,
tracer = Console.WriteLine or Debug/Trace calls.
delGetServer temp = (delGetServer)ar.AsyncState should be changed to ar.AsyncDelegate. You try to get delegate from state, which doesn't work. You can't see exception, because you don't have try/catch and execute
on another thread.
And I have slight suspicion that finishedProc is called once again by EndInvoke. Check if EndInvokeCalled and IsCompleted too.
HTH Alex
"Michael C" <mi*******@optonline.net> wrote in message news:Ju*********************@news4.srv.hcvlny.cv.n et... > Thanks. I'm new to multithreading in .NET. I know the Async
Callback > function is not being called. What's a tracer? > > Michael C > > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message > news:Ok**************@TK2MSFTNGP09.phx.gbl... > > Hi, Michael > > > > Problem is that code is not complete. If you use asynch invoke
like this > one > > [C#] > > public IAsyncResult BeginInvoke( > > object target, > > object[] values, > > AsyncCallback callback, > > object asyncState > > );then there are some differences in syntax. I would suggest to
put > tracers > > in called methods to see process flow. Might happen your called delegate > > really doesn't return.HTHAlex"Michael C" <mi*******@optonline.net> wrote > in > > message news:hZ*********************@news4.srv.hcvlny.cv.n et... > > > Hello > > > > > > Can someone please tell me what I'm doing wrong? I'm writing an > > application > > > that should be using callbacks to perform asynchronous calls to the > Win32 > > > API. Problem is it never reaches my callback function. Any
feedback is > > > appreciated. Also, any references to websites with examples of .NET > async > > > multithreading would be appreciated. Thanks in advance. > > > > > > public serverInfo getSession(string servername) > > > { > > > serverInfo svInfo; > > > Object stateObj = new Object(); > > > delGetServer x = new delGetServer(getServer); > > > IAsyncResult ar = x.BeginInvoke(servername, out svInfo, new > > > AsyncCallback(finishedProc), stateObj); > > > return (svInfo); > > > } > > > > > > public static void getServer(string servername, out serverInfo svInfo) > > > { > > > // performs Win32 API calls to get server info. on network > > > } > > > > > > public delegate void delGetServer (string s1, out serverInfo svInfo); > > > > > > public static void finishedProc(IAsyncResult ar) > > > { > > > serverInfo svInfo; > > > delGetServer temp = (delGetServer)ar.AsyncState; > > > temp.EndInvoke(out svInfo, ar); > > > } > > > > > > > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: dixp |
last post by:
I'm new to writing multithreaded apps and I have a design question. I
have a winforms app and a class which has a method that does processing
which is time intensive. I want the user to be able...
|
by: mihai |
last post by:
What does the standard say about those two? Is any assurance that the
use of STL is thread safe?
Have a nice day,
Mihai.
|
by: Robert Zurer |
last post by:
Can anyone suggest the best book or part of a book on this subject. I'm
looking for an in-depth treatment with examples in C#
TIA
Robert Zurer
robert@zurer.com
|
by: sarge |
last post by:
I would like to know how to perform simple multithreading.
I had created a simple form to test out if I was multithreading
properly, but got buggy results. Sometime the whole thig would lock
up...
|
by: tommy |
last post by:
hi,
i have found a example for multithreading and asp.net
http://www.fawcette.com/vsm/2002_11/magazine/features/chester/
i want to speed up my website ...
if my website is starting, they...
|
by: Rich |
last post by:
Hello,
I have set up a multithreading routine in a Test VB.net
proj, and it appears to be working OK in debug mode and I
am not using synchronization. Multithreading is a new
thing for me, and...
|
by: Sam |
last post by:
Hi,
I have a serious issue using multithreading. A sample application
showing my issue can be downloaded here:
http://graphicsxp.free.fr/WindowsApplication11.zip
The problem is that I need to...
|
by: sandy82 |
last post by:
Whats actuallly multithreading is ... and how threading and
multithreading differ .
Can any1 guide how multithreading is used on the Web .. i mean a
practical scenario in which u use...
|
by: Pradnya Patil |
last post by:
hi ,
I am trying to draw ' html div-tag ' on the screen which will
resemble a rectangle through vb.net code.
I want it to be drawn faster...so I introduced multithreading
using Threadpool. I...
|
by: Ray |
last post by:
Hello,
Greetings! I'm looking for a solid C++ multithreading book. Can you
recommend one? I don't think I've seen a multithreading C++ book that
everybody thinks is good (like Effective C++ or...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |