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 2278
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |