i build a Management system using Monomac c#.
my code is: namespace UWSMacUserProfileModule { public partial class UserProfileViewController : MonoMac.AppKit.NSViewController { #region Constructors // Called when created from unmanaged code public UserProfileViewController (IntPtr handle) : base (handle) { Initialize (); } // Called when created directly from a XIB file [Export ("initWithCoder:")] public UserProfileViewController (NSCoder coder) : base (coder) { Initialize (); } // Call to load from the XIB/NIB file // public UserProfileViewController () : base ("UserProfileView", NSBundle.MainBundle) // { // Initialize (); // } // public UserProfileViewController(): base ("UserProfileView") // { // Initialize (); // } // Call to load from the XIB/NIB file public UserProfileViewController () : base ("UserProfileView", null) {
Initialize ();
}
public ModuleController moduleController;
void Initialize ()
{
//QuerySoulutionReqItem ();
//InitTableView ();
}
#endregion
//strongly typed view accessor
public new NSView View {
get {
return (NSView)base.View;
}
}
public override void LoadView ()
{
base.LoadView ();
InitTableView ();
}
private void InitTableView ()
{
Console.WriteLine ("init tableview");
// MonoMac.AppKit.NSTableView profileTableView = new MonoMac.AppKit.NSTableView (); // profileTableView.Frame = new System.Drawing.RectangleF (20, 20, 960, 760); // this.View.AddSubview (profileTableView); string[] columnArray = new string[] { "项目名称", "负责人", "交付时间", "项目文件" }; for (int i=0; i< columnArray.Length; i++) { NSTableColumn column = new NSTableColumn (i.ToString ()); column.Width = 200f; column.HeaderCell.StringValue = columnArray [i]; tableView.AddColumn (column); } tableView.RowHeight = 44f; tableView.DataSource = new ProfileTableViewDataSource (columnArray);
//tableView.Delegate = new ProfileTableViewDelegate ();
}
public void QuerySoulutionReqItem ()
{
ServerMessage serverMessage = new ServerMessage ();
BackgroundWorker worker = new BackgroundWorker ();
TokenIdModel tokenIdModel = new TokenIdModel ();
tokenIdModel.TokenID = this.GetTokenID ();
worker.DoWork += delegate {
serverMessage = CallWebService.CallWebServices ("SoulutionReqItem_Query", tokenIdModel, GlobalObject.GetWebServiceUrl ());
};
worker.RunWorkerAsync ();
worker.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) =>
{
if (serverMessage != null) {
if (serverMessage.Flag != null) {
if (serverMessage.Flag.Equals ("100")) {
if (serverMessage.Content != null) {
//Console.WriteLine(serverMessage.Content);
JArray jArray = JArray.Parse (serverMessage.Content);
foreach (JObject jObject in jArray) {
// Console.WriteLine(jObject["ReqID"]); // Console.WriteLine(jObject["ReqTitle"]); // Console.WriteLine(jObject["ReqTags"]); // Console.WriteLine(jObject["ReqContent"]); // // Console.WriteLine(jObject["PlanDueTime"]); // Console.WriteLine(jObject["ReqClientName"]); // Console.WriteLine(jObject["Email"]); // Console.WriteLine(jObject["ContactItems"]); // // Console.WriteLine(jObject["ReqFiles"]); // Console.WriteLine(jObject["ReqClientName"]); // Console.WriteLine(jObject["Email"]); // Console.WriteLine(jObject["ContactItems"]);
}
}
} else if (serverMessage.Flag.Equals ("-100")) {
}
}
}
};
}
public string GetTokenID ()
{
return PublicParameters.GetParameter ("TokenID").ToString ().Replace ("\"", "");
}
}
public class TokenIdModel
{
public string TokenID {
get;
set;
}
}
public class ProfileTableViewDataSource:NSTableViewDataSource
{
string[] columnArray;
public ProfileTableViewDataSource (string[] _columnArray)
{
columnArray = _columnArray;
}
public override int GetRowCount (NSTableView tableView)
{
return 100;
}
public override NSObject GetObjectValue (NSTableView tableView, NSTableColumn tableColumn, int row)
{
// if(tableColumn.Identifier.Equals(columnArray[0]) && row.Equals(5)) // { // return NSObject.FromObject("wa o"); // } return NSObject.FromObject("sdss");
}
}
public class ProfileTableViewDelegate:NSTableViewDelegate
{
public ProfileTableViewDelegate ()
{
}
public override float GetRowHeight (NSTableView tableView, int row)
{
return 44f;
}
public override void DidDragTableColumn (NSTableView tableView, NSTableColumn tableColumn)
{
Console.WriteLine (tableColumn.Identifier);
}
}
}
------------- code end ------------
when i click the NSTableview cell frequently(quickly click different cells in short time), the program crash and occur errors:
Stacktrace:
at <0xffffffff> at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) at MonoMac.AppKit.NSApplication.Main (string[]) at UniworkSystemMac.MainClass.Main (string[]) [0x00007] in /Users/dev1/DevSolutions/Uniwork_Solutions/MAC_Projects/UniworkSystemMac/UniworkSystemMac/Main.cs:14 at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr)
Native stacktrace:
Debug info from gdb:
Attaching to process 3604. Reading symbols for shared libraries . done Reading symbols for shared libraries ............................................................................................................................................................................................................................. done 0x9738f095 in __wait4 () 11 0x9738c822 in semaphore_timedwait_trap () 10 0x9738ebe6 in select$DARWIN_EXTSN () 9 0x9738c822 in semaphore_timedwait_trap () 8 0x9738f0ee in __workq_kernreturn () 7 0x9738c822 in semaphore_timedwait_trap () 6 0x9738ec72 in __semwait_signal () 5 "com.apple.libdispatch-manager" 0x9738f9ae in kevent () 4 0x9738f0ee in __workq_kernreturn () 3 0x9738eb3e in recvfrom$UNIX2003 () 2 0x9738c80a in semaphore_wait_trap () * 1 "com.apple.main-thread" 0x9738f095 in __wait4 ()
Thread 11 (process 3604):
0 0x9738c822 in semaphore_timedwait_trap ()
1 0x006132e5 in mono_sem_timedwait (sem=0x7124c8, timeout_ms=2000, alertable=1) at mono-semaphore.c:79
2 0x0059caa4 in async_invoke_thread (data=0x0) at threadpool.c:1527
3 0x00595516 in start_wrapper_internal [inlined] () at :608
4 0x00595516 in start_wrapper (data=0x8846a10) at threads.c:653
5 0x006077fa in thread_start_routine (args=0x89771c) at wthreads.c:294
6 0x006181c1 in inner_start_thread (arg=0x8846a30) at mono-threads-posix.c:49
7 0x0063870d in GC_start_routine (arg=0x4a7fd80) at pthread_support.c:1526
8 0x9752b5b7 in _pthread_start ()
9 0x97515dce in thread_start ()
Thread 10 (process 3604):
0 0x9738ebe6 in select$DARWIN_EXTSN ()
1 0x00612d1f in mono_poll (ufds=0x1bfc800, nfds=1, timeout=-1) at mono-poll.c:76
2 0x0059aeee in tp_poll_wait (p=0x712560) at tpool-poll.c:184
3 0x00595516 in start_wrapper_internal [inlined] () at :608
4 0x00595516 in start_wrapper (data=0x8846bc0) at threads.c:653
5 0x006077fa in thread_start_routine (args=0x8976a0) at wthreads.c:294
6 0x006181c1 in inner_start_thread (arg=0x8847550) at mono-threads-posix.c:49
7 0x0063870d in GC_start_routine (arg=0x4a7fd80) at pthread_support.c:1526
8 0x9752b5b7 in _pthread_start ()
9 0x97515dce in thread_start ()
Thread 9 (process 3604):
0 0x9738c822 in semaphore_timedwait_trap ()
1 0x006132e5 in mono_sem_timedwait (sem=0x712448, timeout_ms=2000, alertable=1) at mono-semaphore.c:79
2 0x0059caa4 in async_invoke_thread (data=0x0) at threadpool.c:1527
3 0x00595516 in start_wrapper_internal [inlined] () at :608
4 0x00595516 in start_wrapper (data=0x1328f250) at threads.c:653
5 0x006077fa in thread_start_routine (args=0x897624) at wthreads.c:294
6 0x006181c1 in inner_start_thread (arg=0x1328f550) at mono-threads-posix.c:49
7 0x0063870d in GC_start_routine (arg=0x4a7fd80) at pthread_support.c:1526
8 0x9752b5b7 in _pthread_start ()
9 0x97515dce in thread_start ()
Thread 8 (process 3604):
0 0x9738f0ee in __workq_kernreturn ()
1 0x9752e0ac in _pthread_workq_return ()
2 0x9752de79 in _pthread_wqthread ()
3 0x97515daa in start_wqthread ()
Thread 7 (process 3604):
0 0x9738c822 in semaphore_timedwait_trap ()
1 0x006132e5 in mono_sem_timedwait (sem=0x712448, timeout_ms=2000, alertable=1) at mono-semaphore.c:79
2 0x0059caa4 in async_invoke_thread (data=0x0) at threadpool.c:1527
3 0x00595516 in start_wrapper_internal [inlined] () at :608
4 0x00595516 in start_wrapper (data=0x88ce490) at threads.c:653
5 0x006077fa in thread_start_routine (args=0x89752c) at wthreads.c:294
6 0x006181c1 in inner_start_thread (arg=0x88ced60) at mono-threads-posix.c:49
7 0x0063870d in GC_start_routine (arg=0x496f120) at pthread_support.c:1526
8 0x9752b5b7 in _pthread_start ()
9 0x97515dce in thread_start ()
Thread 6 (process 3604):
0 0x9738ec72 in __semwait_signal ()
1 0x975b5a49 in nanosleep$UNIX2003 ()
2 0x00606a65 in SleepEx (ms=500, alertable=1) at wthreads.c:842
3 0x0059a018 in monitor_thread (unused=0x0) at threadpool.c:777
4 0x00595516 in start_wrapper_internal [inlined] () at :608
5 0x00595516 in start_wrapper (data=0x88ced60) at threads.c:653
6 0x006077fa in thread_start_routine (args=0x8974b0) at wthreads.c:294
7 0x006181c1 in inner_start_thread (arg=0x88cdf30) at mono-threads-posix.c:49
8 0x0063870d in GC_start_routine (arg=0x496f120) at pthread_support.c:1526
9 0x9752b5b7 in _pthread_start ()
10 0x97515dce in thread_start ()
Thread 5 (process 3604):
0 0x9738f9ae in kevent ()
1 0x91035c71 in _dispatch_mgr_invoke ()
2 0x910357a9 in _dispatch_mgr_thread ()
Thread 4 (process 3604):
0 0x9738f0ee in __workq_kernreturn ()
1 0x9752e0ac in _pthread_workq_return ()
2 0x9752de79 in _pthread_wqthread ()
3 0x97515daa in start_wqthread ()
Thread 3 (process 3604):