c# - Efficiency when setting control styles using reflection -
background
i trying fix behavior double buffering causes crash if control large allocate buffer.
after discussion , trial-and-error, decided best course of action enable double buffering controls if size support (say less 3000x3000 pixels), if exceeds size threshold, programmatically turn off double buffering.
this turns out rather annoying do, getstyle , setstyle methods protected, , there many 3rd party controls need disable double buffering for. overcome this, created helper method disables double buffering via reflection, seemed lesser of evils. monitor size of controls via layout event, , set doublebuffer , optimizeddoublebuffer flags accordingly.
question
i'm not overly familiar reflection, , main question sort of performance impact should expect getting/setting controlstyles via methodinfo.invoke method.
in particular, i'm wondering if guard against setting doublebuffer/optimizeddoublebuffer controlstyles first reading in value (which have done using getstyle() via reflection). or same call setstyle() each time. i'm concerned because layout event called lot, , wouldn't want severely degrade performance double buffering tracking logic.
any input appreciated, in particular performance implications of i'm doing, if has better idea disabling double buffering controls when exceeding size.
i recommend read style first see if need call setstyle. setting style expensive.
a small count of reflection access nothing compared allocating double buffer , drawing. don't think it.
Comments
Post a Comment