每当我在第二次运行后通过 Visual Studio 运行代码时,它都不会退出,这意味着它仍然在运行,但在视觉上它已经关闭,但它可以通过 Taskmanager 看到。我认为它与缓冲区被填充键有关,它无法处理流程(运行代码后没有下面显示的方法,它工作正常)。
_Controls _Movement; //Creates an object of the class
public void MainWindow1_KeyDown(object sender, KeyEventArgs e) //Eventhandler method, being called when key is pressed.
{
if (_Movement == null)
{ //assign value to the object ONCE
_Movement = new _Controls(CharacterBody, CharacterFeet);
}
_Movement.Controlling(e); //calling method whether the key is pressed
}
上面是按下按键时调用方法的代码,它会在每次按键发生时调用方法控制。
class _Controls : MainWindow
{
private RotateTransform rotateAll;
private Image _CharacterBody, _CharacterFeet;
public _Controls(Image _CharacterBody, Image _CharacterFeet)
{
this._CharacterBody = _CharacterBody;
this._CharacterFeet = _CharacterFeet;
}
public void Controlling(KeyEventArgs e)
{
}
}
第二次运行并发送垃圾邮件密钥或密钥后,它不会退出。但是当我直接运行它(.exe)时,它运行良好。
这是输出:
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Users\Unranked\documents\visual studio 2013\Projects\Shooter2D\Shooter2D\bin\Release\Shooter2D.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x1108 has exited with code 259 (0x103).
The thread 0x1550 has exited with code 0 (0x0).
The thread 0x1730 has exited with code 259 (0x103).
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Users\Unranked\documents\visual studio 2013\Projects\Shooter2D\Shooter2D\bin\Release\Shooter2D.exe'. Symbols loaded.
Step into: Stepping over non-user code 'Shooter2D.App..ctor'
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'Shooter2D.App.Main'
Step into: Stepping over non-user code 'Shooter2D.App.InitializeComponent'
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Aero\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Aero.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXml\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Shooter2D.vshost.exe' (CLR v4.0.30319: Shooter2D.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
如何让软件退出?
答案 0 :(得分:0)
您可能想尝试设置
package main
import "fmt"
type Some struct{}
func main() {
cl := Some{}
r, err := &cl.Start("")
fmt.Println(r)
}
func (cs *Some) Start(sg string) (string, error) {
return sg, nil
}
这将强制应用程序在主窗口
后立即关闭
您的申请已被关闭。
旁注:看起来你正试图建立一个游戏循环,WPF可能 不是最好的解决方案。你可能想要研究一下 MonoGame或Unity。