when i use delegate like this:
-----------------
[System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand,
Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
delegate_ReplyFromDataProcess = new
PrepareDelegate_ReplyFromDataProcess(ReplyFromData Process);
delegate_ReplyFromDataProcess.BeginInvoke(m, null, null);
}
delegate void PrepareDelegate_ReplyFromDataProcess(Message m);
private void ReplyFromDataProcess(Message m)
{
IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()),
Int32.Parse(m.LParam.ToString()));
}
-----------------
i met the error:
*********
{"Attempted to read or write protected memory. This is often an
indication that other memory is corrupt."}
*********
but if i changed the code like this:
--------------
[System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand,
Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()),
Int32.Parse(m.LParam.ToString()));
}
--------------
everything is ok,so why and how i can handle this,thanks 2 4072 sh***********@gmail.com wrote: when i use delegate like this:
----------------- [System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { delegate_ReplyFromDataProcess = new PrepareDelegate_ReplyFromDataProcess(ReplyFromData Process); delegate_ReplyFromDataProcess.BeginInvoke(m, null, null); }
delegate void PrepareDelegate_ReplyFromDataProcess(Message m); private void ReplyFromDataProcess(Message m) { IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()), Int32.Parse(m.LParam.ToString())); }
-----------------
i met the error: *********
{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}
*********
but if i changed the code like this:
-------------- [System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()), Int32.Parse(m.LParam.ToString())); } --------------
everything is ok,so why and how i can handle this,thanks
I think the problem is that Delegate.BeginInvoke causes the called
method to run on a different thread, and it looks like you can't get at
the Message across a thread boundary. You might try changing the
delegate signature to use the *members* of Message, and explicitly pass
those, so that the delegate doesn't have to access the Message itself.
ie instead of taking (Message m), the delegate takes (IntPtr LParam,
Int32 Msg, IntPtr WParam). Might work.
--
Larry Lard
Replies to group please
hi,
i've tried the way you said ,but the error is the same
------
delegate void PrepareDelegate_ReplyFromDataProcess(UInt32 wParam, Int32
lParam);
private void ReplyFromDataProcess(UInt32 wParam, Int32 lParam)
{
}
-----
[System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand,
Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
delegate_ReplyFromDataProcess = new
PrepareDelegate_ReplyFromDataProcess(ReplyFromData Process);
delegate_ReplyFromDataProcess.BeginInvoke(UInt32.P arse(m.WParam.ToString()),
Int32.Parse(m.LParam.ToString()), null, null);
base.WndProc(ref m);
}
-----------
can u handle this,thanks
Larry Lard wrote: sh***********@gmail.com wrote: when i use delegate like this:
----------------- [System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { delegate_ReplyFromDataProcess = new PrepareDelegate_ReplyFromDataProcess(ReplyFromData Process); delegate_ReplyFromDataProcess.BeginInvoke(m, null, null); }
delegate void PrepareDelegate_ReplyFromDataProcess(Message m); private void ReplyFromDataProcess(Message m) { IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()), Int32.Parse(m.LParam.ToString())); }
-----------------
i met the error: *********
{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}
*********
but if i changed the code like this:
-------------- [System.Security.Permissions.PermissionSet(System.S ecurity.Permissions.SecurityAction.Demand, Name = "FullTrust")] protected override void WndProc(ref Message m) { IntPtr pnt = dp.OnReply(UInt32.Parse(m.WParam.ToString()), Int32.Parse(m.LParam.ToString())); } --------------
everything is ok,so why and how i can handle this,thanks
I think the problem is that Delegate.BeginInvoke causes the called method to run on a different thread, and it looks like you can't get at the Message across a thread boundary. You might try changing the delegate signature to use the *members* of Message, and explicitly pass those, so that the delegate doesn't have to access the Message itself. ie instead of taking (Message m), the delegate takes (IntPtr LParam, Int32 Msg, IntPtr WParam). Might work.
-- Larry Lard Replies to group please This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Terminal882003 |
last post by:
Hi,
I have a problem in my application(C#) if I using RichTextBox to
continuously display a series of text messages (using method
AppendText()). When application is running, it will stop at some...
|
by: Guy |
last post by:
I have extended the datetimepicker control to incorporate
a ReadOnly property.
I have used the new keyword to implement my own version
of the value property, so that if readonly == true then
it...
|
by: cdj |
last post by:
Hi all,
I've got a picturebox on a form, and a save button. When I go to save,
the app craps out with the following error:
==================
An unhandled exception of type...
|
by: Eric |
last post by:
hi,
I want to convert a C# class into COM, so that I can use the class in C++.
The codes compile and link well. But when I run the program, I got a
exception.
Any comment is welcome. Thanks in...
|
by: Phuff |
last post by:
I have an application that should run in the system tray while open.
It is supposed to be open at all times and I need it to dissapear when
the "X" button is pushed on the form...but without...
|
by: Siv |
last post by:
Hi,
A little while ago I wrote a small program that allowed the user to view
products from a database. The database holds the details of the products
which can be viewed via a form and...
|
by: Rob |
last post by:
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).
My user control includes an Overrides of WndProc...
|
by: Snowbleach |
last post by:
Hello, I am having trouble with the following console application. I
am using delegates/event to make a clock raise an alarm when a certain
amount of time has been reached. The following compiles,...
|
by: Scott Gravenhorst |
last post by:
Windows XP SP3
My application is set to open a SaveFile dialog when an exit is
requested. When I click the app's close button, the save dialog
opens, but when I click to change the folder, the...
|
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: 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: 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...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |