Click to See Complete Forum and Search --> : 'AddHandler' stops working
sporkster
Feb 19th, 2008, 01:07 AM
Hello,
I have a little problem.
I am using AddHandler to intercept incoming SMS messages and it works great, but once I send an sms from my app, the handler slows down. sms's get delayed to over a couple minutes each - IF they come through at all.
Why does sending an sms stop the handler? is there any way to fix this?
Thanks!
petevick
Feb 19th, 2008, 07:16 AM
Without knowing how the handler works, not a lot we can do.
Are you targeting WM5 devices or later - if so take a look at the MessageInterceptor namespace. Article here (http://www.code-magazine.com/article.aspx?quickid=0609051&page=3) may help.
sporkster
Feb 19th, 2008, 12:04 PM
I appologize for the lack of information. It was late :)
I am using WM6 and I used the same line of code used in that article:
AddHandler msgInterceptor.MessageReceived, AddressOf smsInterceptor_MessageReceived
However, I did not use the WithEvents statement used in that article. Is that important as well?
As for sending the SMS, I'm doing it like this:
Dim NewSMS as As New SmsMessage
NewMessage.Body = Body
NewMessage.To.Add(New Recipient(Recipient))
NewMessage.Send()
Thank you for your reply, I'll play around with certain things from that article and hopefully I can fix something here. :)
Shaggy Hiker
Feb 19th, 2008, 07:42 PM
Have you stepped through sending the message? Can you identify where the slowdown is occuring? One possibility is that you are triggering something that you didn't think you were triggering. What that would be can't be determined without looking, but you would see it when stepping through the code, as you'd start wandering through sections you never thought you were visiting. This would actually be the best thing to find, because it would be solvable. There are other possibilities that would be much more difficult, but the first step is to try to narrow down exactly where the slowdown is happening. If you find the why along the way....well, then you're just lucky.
sporkster
Feb 19th, 2008, 08:52 PM
I will give it a shot,
but how do I step through the code that is behind the SMSMessage class and the .send procedure?
Thanks :)
Shaggy Hiker
Feb 20th, 2008, 12:19 PM
First, you pray that the pause is not within code that you didn't write. If your prayers in this matter are not answered, then post that.
The basic issue is that if you didn't write it, your task will be FAR tougher, but you need to eliminate the easier items first.
sporkster
Feb 20th, 2008, 01:52 PM
[QUOTE=sporkster]
AddHandler msgInterceptor.MessageReceived, AddressOf smsInterceptor_MessageReceived
Dim NewSMS as As New SmsMessage
NewMessage.Body = Body
NewMessage.To.Add(New Recipient(Recipient))
NewMessage.Send()
is the only 'code' I have written so I could make sure the functionality met my requirements before I continued.
in the sub smsInterceptor_MessageReceived its as follows:
dim content as smsmessage
content = e.message
label1.text = content
I guess this is going to be a tough one for me as in this particular app I practically wrote nothing and theres still a problem :(
thanks for the ongoing support so far. :)
petevick
Feb 24th, 2008, 03:38 AM
Hi,
does this article (http://msdn2.microsoft.com/en-us/library/bb932385.aspx) help at all?
sporkster
Feb 24th, 2008, 03:42 PM
I must be slacking in my searches!
I hadn't seen that article yet. Thank you. I'll get to reading and hopefully it will help me out.
sporkster
Feb 25th, 2008, 12:59 AM
It appears that I'm doing everything correctly (according to the above articles)
However, it's still having the slow down after the NewMessage.Send command. I'm beginning to wonder if there is some kind of incompatibility with this particular device (although I don't have another to test with) or Windows Mobile 6.
I have it narrowed down to the NewMessage.Send, though. Everything works up until that line.
petevick
Feb 26th, 2008, 01:21 AM
Are you disposing of the object after the send?
If you don't 'send', but receive several messages it is ok?
sporkster
Feb 26th, 2008, 02:17 PM
As long as I don't send, I can receive all messages sent to the device. Once I send, it slows down for about 5 full minutes - at which point I will recieve the delayed messages and all is normal until I send again.
I am not using the dispose property until application closing. I have also tried disposing then removing the handler and adding it again after sending just to see if there was some problem there, but it is clearly a problem after sending as that made no change.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.