[Gtk-sharp-list] GTK# Window Display Issue Outside of Main.cs
Gustavo Rubio
gustavo at 42ideas.mx
Wed Nov 7 01:37:28 UTC 2012
Speaking of, are there any binaries of GTK# 2.99 available?
On Tue, Nov 6, 2012 at 6:53 PM, Andres G. Aragoneses <knocte at gmail.com>wrote:
> And a good tool to fix what just Joe brought up is:
>
> https://github.com/slluis/gui-**thread-check<https://github.com/slluis/gui-thread-check>
>
> This tool will, furthermore, be bundled by default in the next 2.99.1
> release (so one more incentive to upgrade ).
>
>
> On 06/11/12 22:37, Joe Dluzen wrote:
>
>> Though I haven't run your code, my first guess would be threading
>> issues. As with practically all GUI toolkits, components are not only
>> not threadsafe, but code doing anything with the components must be
>> invoked on the same thread, please see here:
>> http://www.mono-project.com/**Responsive_Applications<http://www.mono-project.com/Responsive_Applications>
>>
>> In the code you have not posted, is anything started on new threads, or
>> on the threadpool? If so, you'd need to Invoke() any and all update code
>> to the GUI thread. All speculation right now, sorry.
>>
>> Joe
>>
>>
>> On Tue, Nov 6, 2012 at 2:36 PM, Johnnie Odom <jodom at escambia.k12.fl.us
>> <mailto:jodom at escambia.k12.fl.**us <jodom at escambia.k12.fl.us>>> wrote:
>>
>> Hello Everyone,
>>
>>
>> This is my first day on the mailing list, and as it is I have a
>> question regarding some odd behavior I am encountering.
>>
>>
>> I am writing an application on OS X 10.8 using C#, Mono 2.10.9 and
>> MonoDevelop 3.0.4 (including the Designer views) that makes some
>> simple changes to LDAP. As part of it, I decided to get fancy with
>> GTK#. All is going well, except for one behavior.
>>
>>
>> I have created a window class to display a progress bar and stop
>> button. I have further created a function in this class to update
>> the progress bar with a fraction and text message. In my code, I
>> create a new instance of this window class when real work is
>> happening in another class, and then populate it after every ten
>> iterations of a foreach loop.
>>
>>
>> My problem is that when the window is created FROM THE CLASS DOING
>> REAL WORK, it displays neither the progress bar widget, nor the
>> button. It displays only the window title and then white space
>> below. Only this window displays this behavior -- several other
>> windows that I create over the course of the application all display
>> appropriately.
>>
>>
>> If I instead create the progress bar window in Main.cs and call
>> Show(), it will display just fine. I can even call the function to
>> set its status from Main.cs and it will display correctly.
>>
>>
>> I have tried creating the window in Main.cs and passing it to the
>> class that does the real work later. I have tried creating it in
>> other classes besides the one that does the work. In all cases the
>> behavior is the same -- if the window is created and used solely in
>> Main.cs it will display fine, but if it it ever invoked or created
>> from anywhere else (whether or not it is created in another class or
>> in Main.cs) it will display incorrectly.
>>
>>
>> I have taken to using the debugger and break points to isolate the
>> behavior. If I set a breakpoint immediately after the window is
>> created, it is still blank -- that is, I do not think it is a case
>> that the window is just not keeping pace with any updates I am
>> sending. I have also compared the various values of the window
>> objects and attributes when it is displayed (created and used solely
>> in Main.cs) and when it is not (displayed in any other class) and
>> they seem to be identical.
>>
>>
>> So, I am at a loss, and I would appreciate any advice you might give.
>>
>>
>> I can send any code you think would prove useful, but for now I am
>> sending you the class where I am trying to call the window, and the
>> contents of the window's code-behind.
>>
>>
>> Thank you for any guidance you can give.
>>
>>
>> Johnnie Odom
>>
>> Network Services
>>
>> School District of Escambia County
>>
>>
>> ****************
>>
>>
>> The function from the calling class:
>>
>> public string radiazerMain(string radiazerGroup, string
>> radiazerProfile){
>>
>> Progression MarathonBar = new Progression();
>>
>> MarathonBar.Show();
>>
>> string monologger = "";
>>
>> string lastLine = "Radiazer completed current run." +
>> Environment.NewLine;
>>
>> Array usersToModify = getGroupMembers(radiazerGroup)**;
>>
>> string[] radiusAttribs = new
>> string[]{"dialupAccess","**radiusArapFeatures","**
>> radiusArapSecurity","**radiusArapZoneAccess","**radiusAuthType","**
>> radiusCallbackId","**radiusCallbackNumber","**radiusCalledStationId","**
>> radiusCallingStationId","**radiusCheckItem","radiusClass"**
>> ,"radiusClientIPAddress","**radiusExpiration","**radiusFilterId","**
>> radiusFramedAppleTalkLink","**radiusFramedAppleTalkNetwork",**
>> "radiusFramedAppleTalkZone","**radiusFramedCompression","**
>> radiusFramedIPAddress","**radiusFramedIPNetmask","**
>> radiusFramedIPXNetwork","**radiusFramedMTU","**radiusFramedProtocol","**
>> radiusFramedRoute","**radiusFramedRouting","**
>> radiusGroupName","radiusHint",**"radiusHuntgroupName","**
>> radiusIdleTimeout","**radiusLoginIPHost","**radiusLoginLATGroup","**
>> radiusLoginLATNode","**radiusLoginLATPort","**radiusLoginLATService","**
>> radiusLoginService","**radiusLoginTCPPort","**radiusLoginTime","**
>> radiusPasswordRetry","**radiusPortLimit","**radiusProfileDn","**
>> radiusPrompt","**radiusProxyToRealm","**radiusRealm","**
>> radiusReplicateToRealm","**radiusReplyItem","**radiusServiceType","**
>> radiusSessionTimeout"
>>
> ,
> "radiusSimultaneousUse","**radiusStripUserName","**
> radiusTerminationAction","**radiusTunnelAssignmentId","**
> radiusTunnelClientEndpoint","**radiusTunnelMediumType","**
> radiusTunnelPassword","**radiusTunnelPreference","**
> radiusTunnelPrivateGroupId","**radiusTunnelServerEndpoint","**
> radiusTunnelType","**radiusUserCategory","**radiusVSA"};
>
>>
>>
>> LdapAttributeSet profileTemplate =
>> LdapAttributeSetFiltered(**radiazerProfile, radiusAttribs);
>>
>> profileTemplate.Add(new LdapAttribute("**radiusProfileDn",
>> radiazerProfile));
>>
>>
>> int totalUsersCount = usersToModify.Length;
>>
>> int currentUserCount = 0;
>>
>> int errorCount = 0;
>>
>> MarathonBar.Show();
>>
>>
>> foreach(string userToModify in usersToModify){
>>
>> currentUserCount++;
>>
>> try{
>>
>> monologger = monologger + radiazeModifyUser(**userToModify,
>> profileTemplate);
>>
>> }
>>
>> catch(LdapException LdapFailure){
>>
>> monologger = monologger + "User " + userToModify + " failed. Error
>> is " + LdapFailure.ToString() + Environment.NewLine;
>>
>> errorCount++;
>>
>> }
>>
>> if(((currentUserCount % 10) == 0) || ((totalUsersCount -
>> currentUserCount) < 10)){
>>
>> MarathonBar.setProgress(((**double)currentUserCount /
>> totalUsersCount), totalUsersCount , currentUserCount, errorCount,
>> userToModify);
>>
>> }
>>
>> if(MarathonBar.cancelFromUser)**{
>>
>> lastLine = "Radiazer cancelled by user." + Environment.NewLine;
>>
>> break;
>>
>> }
>>
>> }
>>
>>
>> MarathonBar.Destroy();
>>
>> monologger = monologger + lastLine;
>>
>> return monologger;
>>
>> }
>>
>>
>> *************
>>
>>
>> The Code-Behind:
>>
>>
>> using System;
>>
>>
>> namespace Radiazer2
>>
>> {
>>
>> public partial class Progression : Gtk.Window
>>
>> {
>>
>>
>> public bool cancelFromUser = false;
>>
>>
>> public Progression () :
>>
>> base(Gtk.WindowType.Toplevel)
>>
>> {
>>
>> this.Build ();
>>
>> }
>>
>>
>> public void setProgress(double fractionOfProgress, int totalUnits,
>> int finishedUnits, int errorUnits, string finishedUser){
>>
>> this.progressIndicator.**Fraction = fractionOfProgress;
>>
>> this.progressIndicator.Text = "Completed " + finishedUnits + " of "
>> + totalUnits + " with " + errorUnits + " errors. Current user is " +
>> finishedUser + ".";
>>
>> }
>>
>>
>> protected void OnStopUserClicked (object sender, EventArgs e)
>>
>> {
>>
>> cancelFromUser = true;
>>
>> }
>>
>>
>
>
> ______________________________**_________________
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.**com<Gtk-sharp-list at lists.ximian.com>
> http://lists.ximian.com/**mailman/listinfo/gtk-sharp-**list<http://lists.ximian.com/mailman/listinfo/gtk-sharp-list>
>
--
*Gustavo Rubio*
MX: (664) 608-0659
US: (619) 502-9192
http://42ideas.mx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20121106/de408b94/attachment-0001.html>
More information about the Gtk-sharp-list
mailing list