pretty formating is little buggy, maybe you should leave it as is ;)
if we declare variable outside lock, then do something inside lock, and later invoke it on another thread decompiled code is broken.
Original code:
class OutsideLock : UserControl
{
ulong IamClassMember = 0;
private void DrawBackgroundAsync()
{
ulong IamOutsideLock;
lock (this)
{
++this.IamClassMember;
IamOutsideLock = this.IamClassMember;
}
// Util.DoAllDrawEvents(this.myImage.Dispatcher);
int width = (int) Math.Round((double)this.Width);
int height = (int) Math.Round((double)this.Height);
ThreadPool.QueueUserWorkItem((WaitCallback) (param0 => this.DoDrawWork(IamOutsideLock, width, height)));
}
private void DoDrawWork(ulong iDraw, int width, int height)
{
// bla
}
}
Decompiled code:
internal class OutsideLock : UserControl
{
private ulong IamClassMember;
public OutsideLock()
{
}
private void DoDrawWork(ulong iDraw, int width, int height)
{
}
private void DrawBackgroundAsync()
{
lock (this)
{
OutsideLock iamClassMember = this;
iamClassMember.IamClassMember = iamClassMember.IamClassMember + (long)1;
ulong num = this.IamClassMember;
}
int num1 = (int)Math.Round((double)base.Width);
int num2 = (int)Math.Round((double)base.Height);
ThreadPool.QueueUserWorkItem((object param0) => this.DoDrawWork(num, num1, num2));
}
}
as you can see there is no variable declaration before lock context block, instead its moved inside lock context block.
resulting in error in compiler since call to DoDrawWork is outside lock context block:
>> error CS0103: The name 'num' does not exist in the current context
also what is that italic text!?
what have you done with increment?