Slow/Freezing App while sending Mail with CURLEmailMBS

I have a Window in which a Thread is running which is setting up an Email and then sending it with CURLEmailMBS. While this Thread is working the Main Window of my App is freezing for a moment and then responsive again and then freezing again, over and over again until the Mail has been sent. YieldTime is set to True.

Does anybody know how i can workaround this please?

Do you use a thread and performMT?
Because DNS queries can always block.

What is [quote=223593:@Christian Schmitz]performMT[/quote] please?

I have the following Code in the Run Action of my Thread:

[code] Dim e as new CURLEmailMBS

e.SetFrom “…” // Replaced for Forum
e.Subject = Text_Betreff

e.AddHeader “Mime-Version: 1.0”
e.AddHeader “…” // Replaced for Forum
e.AddReplyTo “…” // Replaced for Forum
e.AddHeader “…” // Replaced for Forum

// e.SMTPPassword = “…” // Replaced for Forum
// e.SMTPUsername = “…” // Replaced for Forum
e.SetServer OptionURL, False
e.AddTo Text_Receipient, “…” // Replaced for Forum

e.PlainText = Text_PlainTextBody
e.HTMLText = Text_HTMLBody

For Each Anhang As FolderItem In Attachments
Dim b As BinaryStream = BinaryStream.Open(Anhang, False)
Dim mb as MemoryBlock = b.read(b.length)
e.AddAttachment mb, EncodingToISO8859MBS(Anhang.Name), “”
Next

dim c as new CURLSMBS

if c.SetupEmail(e) then

c.YieldTime = True

dim er as integer = c.Perform

if er <> 0 then
  [/code]

Try PerformMT instead of Perform.

it moves the actual work to a preemptive thread, so the app is not frozen in case of DNS taking a second to resolve IP.

Thank you, but it’s crashing when i use MT:

[code]Crashed Thread: 13

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
abort() called
*** error for object 0x1a22960: pointer being freed was not allocated

Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x992094da __psynch_mutexwait + 10
1 libsystem_pthread.dylib 0x90c43c73 _pthread_mutex_lock_wait + 99
2 libsystem_pthread.dylib 0x90c41158 pthread_mutex_lock + 120
3 XojoFramework 0x013928e2 0x11dd000 + 1792226
4 XojoFramework 0x013939df threadRun + 442
[/code]

13 com.apple.CoreFoundation 0x913008a1 __CFRunLoopRun + 2113

Thread 13 Crashed: 0 libsystem_kernel.dylib 0x9920962a __pthread_kill + 10 1 libsystem_pthread.dylib 0x90c46664 pthread_kill + 101 2 libsystem_c.dylib 0x98fb98c8 abort + 156 3 libsystem_malloc.dylib 0x917082a2 free + 433 4 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08ea4be4 0x8e9a000 + 44004 5 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08ea5598 0x8e9a000 + 46488 6 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08ea5f5a 0x8e9a000 + 48986 7 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08eabe53 0x8e9a000 + 73299 8 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08ead4ef 0x8e9a000 + 79087 9 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08e9d746 0x8e9a000 + 14150 10 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08e9d928 0x8e9a000 + 14632 11 MySQLCommunityPlugin.xojo_plugin_0.dylib 0x08e9c85c 0x8e9a000 + 10332 12 WAG5.debug 0x005334c7 MySQLPreparedStatement.*SQLSelect%o<RecordSet>%o<MySQLPreparedStatement>A1v + 99 13 WAG5.debug 0x0071d463 WAG5Cache.DB_WAG4_GetCustomerName%s%s + 3189 14 WAG5.debug 0x00b5e2dd Window_SendingMail.Window_SendingMail.Thread_Mail_Run%%o<Window_SendingMail.Window_SendingMail>o<Thread> + 2502 15 WAG5.debug 0x005b54a7 Delegate.IM_Invoke%%o<Thread> + 83 16 WAG5.debug 0x0057f9a1 AddHandler.Stub.0%% + 51 17 XojoFramework 0x01393bf8 0x11dd000 + 1797112 18 libsystem_pthread.dylib 0x90c43794 _pthread_body + 138 19 libsystem_pthread.dylib 0x90c4370a _pthread_start + 155 20 libsystem_pthread.dylib 0x90c40fa6 thread_start + 34

WAG5Cache.DB_WAG4_GetCustomerName contained 2 mySQLPreparedStatements. I replaced them with non prepared statements because no user data is included in the statements. I think it’s working now.

And the UI is behaving normally all the time.

Thank you @Christian Schmitz :slight_smile:

thanks. not sure why mysql plugin crashes.

I’d suspect for this reason <https://xojo.com/issue/40982>

Maybe unrelated, but i just tested my major project in X2015R3 again. If i change prepared statements to unprepared statements the StackOverflow errors reported in <https://xojo.com/issue/41238> also change. I have far too many statements in my project to investigate this further and there are places where the user enters data which is used in statements too, which i can’t replace with unprepared statements. Maybe both Feedback Cases are somehow related to each other?