|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help with delegate callback errorother classes which call this one to receive process messages if they wish. The called routine (the one defining the delegate) is named CASSPrintSQL in namespace CASS. The code is: Private Delegate Sub DisplayMessage(ByVal msg As String) Private _msgListener As DisplayMessage .... Public Sub OnDisplayMessage(ByVal CallerMethod As DisplayMessage) '<== Error _msgListener = CallerMethod End Sub The error is: 'CallerMethod' cannot expose type 'DisplayMessage' in namespace 'CASS' through class 'CassPrintSQL'. I do not understand this compilation error. Can anyone help? Thanks, Flomo --
Show quote
Hide quote
On Apr 30, 1:17 pm, "Flomo Togba Kwele" <F...@community.nospam> wrote: You are exposing a private member of a class through a public method> I have a class which processes for a relatively long time. I want to enable > other classes which call this one to receive process messages if they wish. > > The called routine (the one defining the delegate) is named CASSPrintSQL in > namespace CASS. The code is: > > Private Delegate Sub DisplayMessage(ByVal msg As String) > Private _msgListener As DisplayMessage > ... > Public Sub OnDisplayMessage(ByVal CallerMethod As DisplayMessage) '<== Error > _msgListener = CallerMethod > End Sub > > The error is: > 'CallerMethod' cannot expose type 'DisplayMessage' in namespace 'CASS' through > class 'CassPrintSQL'. > > I do not understand this compilation error. Can anyone help? Thanks, Flomo > -- (which is a no-no since it would override the private modifier). Changing the delegate's modifier to public should fix the problem. Thanks, Seth Rowe "Flomo Togba Kwele" <Flomo@community.nospam> schrieb: => 'Public Delegate Sub...'.>I have a class which processes for a relatively long time. I want to enable > other classes which call this one to receive process messages if they > wish. > > The called routine (the one defining the delegate) is named CASSPrintSQL > in > namespace CASS. The code is: > > Private Delegate Sub DisplayMessage(ByVal msg As String) > Private _msgListener As DisplayMessage See above. The /public/ method exposes a parameter of type > ... > Public Sub OnDisplayMessage(ByVal CallerMethod As DisplayMessage) '<== > Error > _msgListener = CallerMethod > End Sub > > The error is: > 'CallerMethod' cannot expose type 'DisplayMessage' in namespace 'CASS' > through > class 'CassPrintSQL'. > > I do not understand this compilation error. Can anyone help? Thanks, Flomo 'DisplayMessage', which requires the delegate type 'DisplayMessage' to be visible outside the class too. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Thanks to you both for getting me over that hump.
Now to be greedy - it compiles but does not work as I expected. After instantiating the object to be called, which also handles the delegate, I issue the following in the calling routine: cass.OnDisplayMessage(AddressOf GetMessage) .... Private Sub GetMessage(ByVal msg As String) lblInfo.Text = msg End Sub where cass is the instance name of the called routine. In that routine I defined: Private Sub SendMessage(ByVal msg As String) If _msgListener IsNot Nothing Then _msgListener.BeginInvoke(msg, Nothing, Nothing) End If End Sub I called the SendMessage routine with different messages 6 times and I can see this in the debugger. But I do not get any output in the Label. Any ideas? Thanks again, Flomo -- Show quoteHide quoteFlomo Togba Kwele wrote: > I have a class which processes for a relatively long time. I want to enable > other classes which call this one to receive process messages if they wish. > > The called routine (the one defining the delegate) is named CASSPrintSQL in > namespace CASS. The code is: > > Private Delegate Sub DisplayMessage(ByVal msg As String) > Private _msgListener As DisplayMessage > ... > Public Sub OnDisplayMessage(ByVal CallerMethod As DisplayMessage) '<== > Error _msgListener = CallerMethod > End Sub > > The error is: > 'CallerMethod' cannot expose type 'DisplayMessage' in namespace 'CASS' through > class 'CassPrintSQL'. > > I do not understand this compilation error. Can anyone help? Thanks, Flomo -- Hello, Flomo,
Is the delegate defined in a class or user control? I tested following code: Public Class Class1 Public Delegate Sub DisplayMessage(ByVal msg As String) Private _msgListener As DisplayMessage Public Sub OnDisplayMessage(ByVal CallerMethod As DisplayMessage) _msgListener = CallerMethod End Sub Public Sub SendMessage(ByVal msg As String) If _msgListener IsNot Nothing Then _msgListener.Invoke(msg) End If End Sub End Class And tested it in a win form application, it seems to work well. Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Thanks for responding, Luke.
The delegate is defined in a regular class (CassPrintSql) which does a lot of processing. The calling routine is a UserControl providing the GUI interface. That is the one which is supposed to display messages coming from CassPrintSql (the one containing the delegate). I used the BeginInvoke method on the delegate because some of the processes in this class take more than a few minutes. If I don't use an asynchronous delegate, the messages will be blocked until the entire class is complete. I don't know why it didn't work as coded. Any ideas? Thanks, Flomo Hello,
If you just have a test, use invoke instead of beginInvoke(), what will happen to the Messages? Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Luke,
If I change from BeginInvoke to Invoke, the result is the same - no output to GUI interface until the calling program is complete. Flomo -- Hello,
If you use a simple class instead of your original CassPrintSql, to define the delegate, what will happen? I suspect other code in CassPrintSql may cause the problem so that the delegate doesn't work correctly. I tested a simple class on my side, and I didn't find the problem. Sincerely, Luke Zhang Microsoft Online Community Support ================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Luke,
Thanks for the reply. I had to call CSS. Flomo Luke Zhang [MSFT] wrote: Show quoteHide quote > Hello, > > If you use a simple class instead of your original CassPrintSql, to define > the delegate, what will happen? I suspect other code in CassPrintSql may > cause the problem so that the delegate doesn't work correctly. I tested a > simple class on my side, and I didn't find the problem. > > Sincerely, > > Luke Zhang > > Microsoft Online Community Support > ================================================== > Get notification to my posts through email? Please refer to > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications. > > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues > where an initial response from the community or a Microsoft Support > Engineer within 1 business day is acceptable. Please note that each follow > up response may take approximately 2 business days as the support > professional working with you may need further investigation to reach the > most efficient resolution. The offering is not appropriate for situations > that require urgent, real-time or phone-based interactions or complex > project analysis and dump analysis issues. Issues of this nature are best > handled working with a dedicated Microsoft Support Engineer by contacting > Microsoft Customer Support Services (CSS) at > http://msdn.microsoft.com/subscriptions/support/default.aspx. > ================================================== > > This posting is provided "AS IS" with no warranties, and confers no rights. > >
Strange Date Problem
there is no 64-bit Jet (MS Access) OLEDB driver. Problem with: Use the following method to smooth edges of screen fonts: if ClearType is selected COM problem Publishing problem a vb calculator, but with a twist.?? Can someone help me with this menu? Send keystroke to a datagridview control Forms Persistent settings |
|||||||||||||||||||||||